potentially solving disconnection on idling
This commit is contained in:
@@ -19,22 +19,28 @@ export function SocketProvider({ children }: { children: React.ReactNode }) {
|
|||||||
|
|
||||||
const [$ws, set$ws] = useState<Socket>(null);
|
const [$ws, set$ws] = useState<Socket>(null);
|
||||||
|
|
||||||
const initiateSocketStabilityListeners = useCallback((socketConnection: Socket) => {
|
const initiateSocketStabilityListeners = useCallback(
|
||||||
socketConnection.on('connect', () => {
|
(socketConnection: Socket) => {
|
||||||
toast.success('sockets connected');
|
socketConnection.on('connect', () => {
|
||||||
});
|
toast.success('sockets connected');
|
||||||
|
});
|
||||||
|
|
||||||
socketConnection.io.on('close', () => {
|
socketConnection.io.on('close', () => {
|
||||||
console.error('SOCKET | connection closed likely due to idling or manual disconnect');
|
console.error('SOCKET | connection closed likely due to idling or manual disconnect');
|
||||||
toast('unplugging');
|
toast('unplugging');
|
||||||
});
|
|
||||||
|
|
||||||
// client-side errors
|
socketConnection.disconnect();
|
||||||
socketConnection.on('connect_error', (err) => {
|
set$ws(undefined);
|
||||||
console.error(`SOCKETS | ${err.message}`);
|
});
|
||||||
toast.error('sorry...this is our bad...please refresh with cmd + r');
|
|
||||||
});
|
// client-side errors
|
||||||
}, []);
|
socketConnection.on('connect_error', (err) => {
|
||||||
|
console.error(`SOCKETS | ${err.message}`);
|
||||||
|
toast.error('sorry...this is our bad...please refresh with cmd + r');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[set$ws],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!jwtToken) {
|
if (!jwtToken) {
|
||||||
|
|||||||
Reference in New Issue
Block a user