disconnect method

  1. @override
void disconnect()
override

Implementation

@override
void disconnect() {
  logger.debug('disconnect()');
  if (_closed) return;
  // Don't wait for the WebSocket 'close' event, do it now.
  _closed = true;
  _connected = false;
  _onClose(true, 0, 'Client send disconnect');
  try {
    if (_ws != null) {
      _ws!.close();
    }
  } catch (error) {
    logger
        .error('close() | error closing the WebSocket: ' + error.toString());
  }
}