close method

Future close()

close connection to NATS server unsub to server but still keep subscription list at client

Implementation

Future close() async {
  _setStatus(Status.closed);
  _backendSubs.forEach((_, s) => s = false);
  _inboxs.clear();
  await _wsChannel?.sink.close();
  _wsChannel = null;
  await _secureSocket?.close();
  _secureSocket = null;
  await _tcpSocket?.close();
  _tcpSocket = null;

  _buffer = [];
  _clientStatus = _ClientStatus.closed;
}