send static method

StompFrame send({
  1. required String destination,
  2. String? body,
  3. Uint8List? bodyBytes,
  4. String? contentType,
  5. String? receipt,
  6. String? transaction,
  7. Map<String, String>? additionalHeaders,
})

Creates a SEND frame

Implementation

static StompFrame send({
  required String destination,
  String? body,
  Uint8List? bodyBytes,
  String? contentType,
  String? receipt,
  String? transaction,
  Map<String, String>? additionalHeaders,
}) {
  final headers = <String, String>{
    StompHeaders.destination: destination,
  };

  if (contentType != null) headers[StompHeaders.contentType] = contentType;
  if (receipt != null) headers[StompHeaders.receipt] = receipt;
  if (transaction != null) headers[StompHeaders.transaction] = transaction;
  if (additionalHeaders != null) headers.addAll(additionalHeaders);

  Uint8List? frameBody;
  if (body != null) {
    frameBody = Uint8List.fromList(utf8.encode(body));
  } else if (bodyBytes != null) {
    frameBody = bodyBytes;
  }

  if (frameBody != null) {
    headers[StompHeaders.contentLength] = frameBody.length.toString();
  }

  return StompFrame(command: StompCommands.send, headers: headers, body: frameBody);
}