dispose method

void dispose()

Dispose of the connection so stops all activities and cannot be re-used. For the connection to be garbage collected.

If the Connection instance was created with getInstance, you must also call Connection.removeInstance after calling dispose.

If you intend to re-use the connection later, consider just calling close instead.

Implementation

void dispose() {
  close();
  RosterManager.removeInstance(this);
  PresenceManager.removeInstance(this);
  MessageHandler.removeInstance(this);
  PingManager.removeInstance(this);
  ServiceDiscoveryNegotiator.removeInstance(this);
  StreamManagementModule.removeInstance(this);
  CarbonsNegotiator.removeInstance(this);
  MAMNegotiator.removeInstance(this);
  reconnectionManager?.close();
  _socket?.close();
}