Skip to content

Commit bc3773b

Browse files
committed
rejoin bug fixed
1 parent a0c4d1e commit bc3773b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

app/src/helperFunctions/socket.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ import config from '../../../config';
1616
let socket = null;
1717

1818
export const initializeSocket = () => {
19-
if (socket) socket.connect();
20-
if (!socket) {
21-
socket = io(config.API_BASE_URL, {
22-
transports: ['websocket'],
23-
forceNew: true
24-
});
25-
console.log('A user connected');
26-
console.log('socket:', socket);
27-
}
19+
socket = io(config.API_BASE_URL, {
20+
transports: ['websocket'],
21+
// will force new socket connection if re-joining to prevent double emits
22+
forceNew: true
23+
});
24+
console.log('A user connected');
25+
console.log('socket:', socket);
26+
// }
2827
};
2928

3029
export const getSocket = () => {

0 commit comments

Comments
 (0)