StompServer

StompServer

new StompServer(config)

Source:
Parameters:
Name Type Description
config ServerConfig

Configuration for STOMP server

Extends

  • EventEmitter

Members

send

Send message to topic

Source:

Methods

(private) _checkSubMatchDest(sub, args) → {boolean}

Test if the input subscriber has subscribed to the target destination.

Source:
Parameters:
Name Type Description
sub

the subscriber

args

onSend args

Returns:
Type:
boolean

true if the input subscription matches destination

(private) _sendToSubscriptions(socket, args)

Send message to matching subscribers.

Source:
Parameters:
Name Type Description
socket object

websocket to send the message on

args string

onSend args

addMiddleware(command, handler)

Add middle-ware for specific command

Source:
Parameters:
Name Type Description
command 'connect' | 'disconnect' | 'send' | 'subscribe' | 'unsubscribe'

Command to hook

handler function

function to add in middle-ware

afterConnectionClose(socket)

After connection close

Source:
Parameters:
Name Type Description
socket

WebSocket connection that has been closed and is dying

frameParser(frame) → {MsgFrame}

Parse frame to object for reading

Source:
Parameters:
Name Type Description
frame MsgFrame

Message frame

Returns:
Type:
MsgFrame

modified frame

frameSerializer(frame) → {MsgFrame}

Serialize frame to string for send

Source:
Parameters:
Name Type Description
frame MsgFrame

Message frame

Returns:
Type:
MsgFrame

modified frame

heartbeatOff(socket)

Heart-beat: Turn Off for given socket

Source:
Parameters:
Name Type Description
socket WebSocket

Destination WebSocket

heartbeatOn(socket, interval, serverSide)

Heart-beat: Turn On for given socket

Source:
Parameters:
Name Type Description
socket WebSocket

Destination WebSocket

interval number

Heart-beat interval

serverSide boolean

If true then server is responsible for sending pings

removeMiddleware(command, handler)

Remove middle-ware specific for command

Source:
Parameters:
Name Type Description
command 'connect' | 'disconnect' | 'send' | 'subscribe' | 'unsubscribe'

Command with hook

handler function

function to remove from middle-ware

setMiddleware(command, handler)

Clear and set middle-ware for specific command

Source:
Parameters:
Name Type Description
command 'connect' | 'disconnect' | 'send' | 'subscribe' | 'unsubscribe'

Command to hook

handler function

function to add in middle-ware

subscribe(topic, callbackopt, headers) → {string}

Subscribe topic

Source:
Parameters:
Name Type Attributes Description
topic string

Subscribed destination, wildcard is supported

callback OnSubscribedMessageCallback <optional>

Callback function

headers object

Optional headers, used by client to provide a subscription ID (headers.id)

Returns:
Type:
string

Subscription id, when message is received event with this id is emitted

Example
stompServer.subscribe('/test.data', function(msg, headers) {});
//or alternative
var subs_id = stompServer.subscribe('/test.data');
stompServer.on(subs_id, function(msg, headers) {});

unsubscribe(id) → {boolean}

Unsubscribe topic with subscription id

Source:
Parameters:
Name Type Description
id string

Subscription id

Returns:
Type:
boolean

Subscription is deleted

Events

connected

Client connected event, emitted after connection established and negotiated

Properties:
Name Type Description
sessionId string
headers object
Source:
Type:
  • object

connecting

Client connecting event, emitted after socket is opened.

Properties:
Name Type Description
sessionId string
Source:
Type:
  • object

disconnected

Client disconnected event

Properties:
Name Type Description
sessionId string
Source:
Type:
  • object

send

Event emitted when broker send message to subscribers

Properties:
Name Type Description
dest string

Destination

frame string

Message frame

Source:
Type:
  • object

subscribe

Client subscribe event, emitted when client subscribe topic

Properties:
Name Type Description
id string

Subscription id

sessionId string

Socket session id

topic string

Destination topic

tokens Array.<string>

Tokenized topic

socket object

Connected socket

Source:
Type:
  • object

unsubscribe

Client subscribe event, emitted when client unsubscribe topic

Properties:
Name Type Description
id string

Subscription id

sessionId string

Socket session id

topic string

Destination topic

tokens Array.<string>

Tokenized topic

socket object

Connected socket

Source:
Type:
  • object
Returns:
Type:
boolean