disconnect method
Disconnect the client from the server
Implementation
@override
Future<void> disconnect() async {
_wantsConnection = false;
_connectGeneration++;
_stopPingTimer();
if (_transport == null) {
// No transport was ever opened, but a failed first connect can have
// left the status on reconnecting.
updateConnectionStatus(ConnectionStatus.disconnected);
return;
}
await tryCatchIgnore(() async {
await _transport!.close();
});
_transport = null;
_sessionId = null;
_lastPongAt = null;
_outboundQueue?.close();
_outboundQueue = null;
for (final plugin in plugins) {
plugin.onDisconnected();
}
updateConnectionStatus(ConnectionStatus.disconnected);
}