subscribe method

Future<StompSubscription> subscribe({
  1. required PeerId peerId,
  2. required String destination,
  3. String? subscriptionId,
  4. StompAckMode ackMode = StompAckMode.auto,
  5. bool requestReceipt = false,
  6. Map<String, String>? headers,
})

Subscribes to a destination on a specific peer

Implementation

Future<StompSubscription> subscribe({
  required PeerId peerId,
  required String destination,
  String? subscriptionId,
  StompAckMode ackMode = StompAckMode.auto,
  bool requestReceipt = false,
  Map<String, String>? headers,
}) async {
  final client = _clients[peerId];
  if (client == null || !client.isConnected) {
    throw StompConnectionException('No active connection to peer $peerId');
  }

  return await client.subscribe(
    destination: destination,
    id: subscriptionId,
    ackMode: ackMode,
    requestReceipt: requestReceipt,
    headers: headers,
  );
}