API Reference 0.7.1stomp_websocket

stomp_websocket library

Functions

Future<StompClient> connectWith(WebSocket socket, {String host, String login, String passcode, List<int> heartbeat, void onConnect(StompClient client, Map<String, String> headers), void onDisconnect(StompClient client), void onError(StompClient client, String message, String detail, Map<String, String> headers), void onFault(StompClient client, error, stackTrace)}) #

Connects a STOMP server with the given Web socket.

  • onError -- callback when the ERROR frame is received.
  • onFault -- callback when an exception or a WebSocket error event is received.
Future<StompClient> connectWith(WebSocket socket, {
   String host, String login, String passcode, List<int> heartbeat,
   void onConnect(StompClient client, Map<String, String> headers),
   void onDisconnect(StompClient client),
   void onError(StompClient client, String message, String detail, Map<String, String> headers),
   void onFault(StompClient client, error, stackTrace)})
=> _WSStompConnector.startWith(socket).then((_WSStompConnector connector)
 => StompClient.connect(connector,
   host: host, login: login, passcode: passcode, heartbeat: heartbeat,
   onConnect: onConnect, onDisconnect: onDisconnect,
   onError: onError, onFault: onFault));

Future<StompClient> connect(String url, {String host, String login, String passcode, List<int> heartbeat, void onConnect(StompClient client, Map<String, String> headers), void onDisconnect(StompClient client), void onError(StompClient client, String message, String detail, Map<String, String> headers), void onFault(StompClient client, error, stackTrace)}) #

Connects a STOMP server, and instantiates a StompClient to represent the connection.

import "package:stomp/stomp.dart";
import "package:stomp/websocket.dart" show connect;

void main() {
  connect("foo.server.com").then((StompClient stomp) {
    stomp.subscribeString("/foo", (String message) {
      print("Recieve $message");
    });

    stomp.sendString("/foo", "Hi, Stomp");
  });
}
  • url -- the URL of WebSocket to connect, such as 'ws://127.0.0.1:1337/foo'.
  • onError -- callback when the ERROR frame is received.
  • onFault -- callback when an exception or a WebSocket error event is received.
Future<StompClient> connect(String url, {
   String host, String login, String passcode, List<int> heartbeat,
   void onConnect(StompClient client, Map<String, String> headers),
   void onDisconnect(StompClient client),
   void onError(StompClient client, String message, String detail, Map<String, String> headers),
   void onFault(StompClient client, error, stackTrace)})
=> connectWith(new WebSocket(url),
   host: host, login: login, passcode: passcode, heartbeat: heartbeat,
   onConnect: onConnect, onDisconnect: onDisconnect,
   onError: onError, onFault: onFault);