close method

Future<void> close()

Closes the connection

Implementation

Future<void> close() async {
  if (_state == StompServerConnectionState.disconnected) return;

  setState(StompServerConnectionState.disconnecting);

  // Abort all active transactions
  _transactionManager.abortAllTransactions();

  // Clear subscriptions
  _subscriptionManager.clear();
  _ackManager.clear();

  // Close stream
  if (!stream.isClosed) {
    try {
      await stream.close();
    } catch (e) {
      _logger.warning('Error closing stream for ${peerId}: $e');
    }
  }

  _frameController.close();
  setState(StompServerConnectionState.disconnected);
}