socket.io-client-dart
socket.io-client-dart copied to clipboard
dispose() and clearListeners() not working
Hello, I am using socket.io and when user logout I call
void logout() {
debugPrint("will logout socket");
chatSocket?.clearListeners();
chatSocket?.dispose();
}
I use websocketService class and use it with getIt
class WebsocketService {
// final Socket? socket;
Socket? chatSocket;
WebsocketService()
: chatSocket =
io("$Server/${SocketConstants.ChatNameSpace}", <String, dynamic>{
'transports': <String>['websocket'],
'query': <String, dynamic>{
"access_token": token,
}
});
void logout() {
debugPrint("will logout socket");
chatSocket?.clearListeners();
chatSocket?.dispose();
}
}
after calling logout function the app keeps handle sockets and doesn't clear listeners
which version are you using?
@jumperchen The latest version After debugging I found the issue was I create the connection 2 times so when I close connection it closes 1 connection. you must handle that.
Please see https://github.com/rikulo/socket.io-client-dart/issues/258#issuecomment-1049585853
Any updates i faces the same in version 2.0.0