This commit is contained in:
2024-02-08 09:10:53 -05:00
commit 91767b9d67
37 changed files with 37612 additions and 0 deletions

22
services/socket.js Normal file
View File

@@ -0,0 +1,22 @@
import io from 'socket.io-client';
import {Toast} from 'react-native-toast-message'
let socket;
export const connectSocket = (userId) => {
socket = io('http://localhost:1989', {
query: { userId },
transports: ['websocket']
});
socket.on('notification', (notification) => {
Toast.show({
type: 'info',
text1: notification.message,
});
});
}
export const disconnectSocket = () => {
if (socket) socket.disconnect();
}