Construct a new WSTransport instance
the connection options
the transport constructor function
A flag indicating whether the transport constructor function allows additional options
The emitter used for emitting events
The connection options
The WebSocket instance as created by the constructor function
The transport constructor function
Directly close the websocket connection.
Establish a websocket connection, with provided connection options and callback functions.
the connection request
a handshake deserialiser
Send a binary message to the server.
the message to send
true if the message was sent successfully
Handler function for the WebSocket's onmessage event.
the message that was received
Remove a listener from a specified event.
Example:
// Bind a single listener to the 'foo' event and then deregister it
var listener = function() {};
stream.on('foo', listener);
stream.off('foo', listener);
Example:
// Bind a listener to the 'foo' event and deregister all listeners
var listener = function() {};
stream.on('foo', listener);
stream.off('foo');
the listener to remove. All listeners for the event are removed if this is not specified. This argument is ignored if the first argument is a CallbackMap.
this stream.
Register listeners against events.
A single listener may be bound to an event by passing the event name and listener function.
Multiple listeners may be bound by passing in a CallbackMap, mapping event names to listener functions.
Example:
// Bind a single listener to the 'foo' event
stream.on('foo', function(arg1, arg2) {
console.log("Called for 'foo' event", arg1, arg2);
});
Example:
// Bind multiple listeners
stream.on({
foo : function() { ... },
bar : function() { ... },
baz : function() { ... }
});
It is possible to bind multiple listeners to the same event. In this case, the listeners will be called in the order they were bound.
the event name or CallbackMap mapping event names to listeners
the listener to bind to the event, if passed as string. This argument is ignored if the first argument is a CallbackMap.
this stream.
Copyright © 2025 DiffusionData Ltd. All Rights Reserved.
The implementation of the Transport interface using Web Sockets