send static method
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);
}