STOMP Dart client for communicating with STOMP complaint messaging brokers and servers.
Stomp Dart Client is distributed under an Apache 2.0 License.
Add this to your pubspec.yaml
(or create it):
dependencies:
stomp:
Then run the Pub Package Manager (comes with the Dart SDK):
pub install
import "package:stomp/stomp.dart";
import "package:stomp/vm.dart" show connect;
void main() {
connect("foo.server.com").then((StompClient client) {
client.subscribeString("/foo",
(Map<String, String> headers, String message) {
print("Recieve $message");
});
client.sendString("/foo", "Hi, Stomp");
});
}
There are basically a few alternative ways to communicate:
- JSON objects:
sendJson()
andsubscribeJson()
- Strings:
sendString()
andsubscribeString()
- Bytes:
sendBytes()
andsubscribeBytes()
- BLOB (huge data):
sendBlob()
andsubscribeBlob()
Please refer to StompClient for more information.
The same as the above, except import websocket.dart
instead of vm.dart
:
import "package:stomp/stomp.dart";
import "package:stomp/websocket.dart" show connect;
//the rest is the same as running on Dart VM
- Support STOMP 1.2 or above
- Support UTF-8 encoding
- Heart beat not supported.