API Reference 0.7.1stomp_impl_util

stomp_impl_util library

Properties

const String ABORT #

const String ABORT = "ABORT"

const String ACK #

const String ACK = "ACK"

const String BEGIN #

const String BEGIN = "BEGIN"

const String COMMIT #

const String COMMIT = "COMMIT"

const String CONNECT #

const String CONNECT = "CONNECT"

const String CONNECTED #

const String CONNECTED = "CONNECTED"

const String DISCONNECT #

const String DISCONNECT = "DISCONNECT"

const String ERROR #

const String ERROR = "ERROR"

const String MESSAGE #

const String MESSAGE = "MESSAGE"

const String NACK #

const String NACK = "NACK"

const String RECEIPT #

const String RECEIPT = "RECEIPT"

const String SEND #

const String SEND = "SEND"

const String STOMP #

const String STOMP = "STOMP"

const String SUBSCRIBE #

const String SUBSCRIBE = "SUBSCRIBE"

const String UNSUBSCRIBE #

const String UNSUBSCRIBE = "UNSUBSCRIBE"

Functions

Map<String, String> addHeaders(Map<String, String> headers, Map<String, String> extra) #

Adds the additional headers ( extra) into a given header ( headers). If both headers and extra are null, null is returned. Otherwise, a non-null map is returned.

Map<String, String> addHeaders(Map<String, String> headers, Map<String, String> extra) {
 if (headers != null || extra != null) {
   if (headers == null)
     headers = new LinkedHashMap();
   if (extra != null)
     headers.addAll(extra);
 }
 return headers;
}

Future writeStreamFrame(StompConnector connector, String command, Map<String, String> headers, Stream<List<int>> stream) #

Write a frame from the given stream

Future writeStreamFrame(StompConnector connector, String command,
   Map<String, String> headers, Stream<List<int>> stream) {
 writeHeaders(connector, command, headers);
 return connector.writeStream(stream).then((_) {
   connector.writeEof();
 });
}

void writeDataFrame(StompConnector connector, String command, Map<String, String> headers, String string, [List<int> bytes]) #

Write a data frame used by SEND, ERROR and MESSAGE.

void writeDataFrame(StompConnector connector, String command,
   Map<String, String> headers, String string, [List<int> bytes]) {
 writeHeaders(connector, command, headers, endOfHeaders: false);

 if (headers == null || headers[CONTENT_LENGTH] == null) {
   int len = 0;
   if (bytes != null) {
     len = bytes.length;
   } else if (string != null && !string.isEmpty) {
     bytes = UTF8.encode(string);
     len = bytes.length;
   }
   connector..write(CONTENT_LENGTH)..write(':')
     ..write(len.toString())..writeLF();
 }

 connector.writeLF();
 connector.write(string, bytes);
 connector.writeEof();
}

void writeSimpleFrame(StompConnector connector, String command, Map<String, String> headers) #

Write a simple frame, such as STOMP, CONNECTED.

void writeSimpleFrame(StompConnector connector, String command,
   Map<String, String> headers) {
 writeHeaders(connector, command, headers);
 connector.writeEof();
}

void writeHeaders(StompConnector connector, String command, Map<String, String> headers, {bool endOfHeaders: true}) #

Writes the headers (excluding body and End-of-Frame)

  • endOfHeaders - specifies whether to write an empty line to indicate the end of the headers.

void writeHeaders(StompConnector connector, String command,
   Map<String, String> headers, {bool endOfHeaders: true}) {
 connector
   ..write(command)
   ..writeLF();

 if (headers != null) {
   for (final String name in headers.keys) {
     connector
       ..write(_escape(name))
       ..write(':')
       ..write(_escape(headers[name]))
       ..writeLF();
   }
 }

 if (endOfHeaders)
   connector.writeLF();
}

Classes