disconnect method

void disconnect(
  1. String reason
)

If anything goes wrong, disconnect with reason.

Implementation

void disconnect(String reason) {
  if (socket != null) {
    socket.close();
    socket = null;
  }

  channels.forEach((int channelId, Channel channel) {
    if (!channel.sentClose && channel.closed != null) channel.closed();
  });
  channels.clear();

  if (debugPrint != null) {
    debugPrint('SSHTransport.disconnected: $reason');
  }

  if (disconnected != null) disconnected();
}