disconnect method

void disconnect()

Closes the socket connection, effectively logging the user out.

Implementation

void disconnect() {
  _invalidateGatewayResponseTimer();
  _resetGatewayCounters();
  _logger.i('disconnect()');
  if (_closed) return;
  // Don't wait for the WebSocket 'close' event, do it now.
  _closed = true;
  _connected = false;
  _registered = false;
  _onClose(true, 0, 'Client send disconnect');
  try {
    txSocket.close();
  } catch (error) {
    _logger.e('close() | error closing the WebSocket: $error');
  }
}