sendMessage method

Future<String?> sendMessage({
  1. required PeerId peerId,
  2. required String destination,
  3. String? body,
  4. String? contentType,
  5. bool requestReceipt = false,
  6. Map<String, String>? headers,
})

Sends a message to a destination on a specific peer

Implementation

Future<String?> sendMessage({
  required PeerId peerId,
  required String destination,
  String? body,
  String? contentType,
  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.send(
    destination: destination,
    body: body,
    contentType: contentType,
    requestReceipt: requestReceipt,
    headers: headers,
  );
}