close method

void close()

Implementation

void close() {
  if (state == XmppConnectionState.SocketOpening) {
    throw Exception('Closing is not possible during this state');
  }
  if (state != XmppConnectionState.Closed &&
      state != XmppConnectionState.ForcefullyClosed &&
      state != XmppConnectionState.Closing) {
    if (_socket != null) {
      try {
        setState(XmppConnectionState.Closing);
        _socket!.write('</stream:stream>');
      } on Exception {
        Log.d(TAG, 'Socket already closed');
      }
    }
    authenticated = false;
  }
}