disconnect method

void disconnect()

Disconnect from the remote server.

Throws a StateError if the client is disconnected.

Implementation

void disconnect() {
  if (!_hasConnected) {
    throw StateError('Client is not connected');
  }

  _socket.destroy();

  _hasConnected = false;
}