Giter VIP home page Giter VIP logo

stompbrokerjs's Introduction

Known Vulnerabilities GitHub issues

StompBrokerJS

NodeJS StompBroker

This is simple NodeJs STOMP 1.1 broker for embedded usage.

Features

  • Destination wildcards
    • . is used to separate names in a path
    • * is used to mach any name in a path
    • ** is used to recursively match path names

#TODO

  • Authorization
  • Heartbeat
  • Acknowledgment
  • Async send messages
  • Transactions
  • Composite Destinations
  • Message selectors

#Changelog

  • 0.1.0 First working version.
  • 0.1.1 Added wildcards to destination, change subscribe method [no backward compatibility]
  • 0.1.2 Bug fixes, changed websocket library, updated documentation.
  • 0.1.3 Unsubscribe on server, updated documentation, added events.

#Example

var http = require("http");
var StompServer = require('stompServer');

var server = http.createServer();
var stompServer = new StompServer({server: server});

server.listen(61614);

stompServer.subscribe("/**", function(msg, headers) {
  var topic = headers.destination;
  console.log(topic, "->", msg);
});

stompServer.send('/test', {}, 'testMsg');

#Documentation

Classes

StompServerEventEmitter

Typedefs

ServerConfig : object

STOMP Server configuration

OnSubscribedMessageCallback : function

Subscription callback method

MsgFrame : object

Message frame

StompServer ⇐ EventEmitter

Kind: global class
Extends: EventEmitter

new StompServer(config)

Param Type Description
config ServerConfig Configuration for STOMP server

stompServer.onUnsubscribe() ⇒ boolean

Kind: instance method of StompServer

stompServer.subscribe(topic, [callback]) ⇒ string

Subsribe topic

Kind: instance method of StompServer
Returns: string - Subscription id, when message is received event with this id is emitted

Param Type Description
topic string Subscribed destination, wildcard is supported
[callback] OnSubscribedMessageCallback Callback function

Example

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

stompServer.unsubscribe(id) ⇒ boolean

Unsubscribe topic with subscription id

Kind: instance method of StompServer
Returns: boolean - Subscription is deleted

Param Type Description
id string Subscription id

stompServer.send(topic, headers, body)

Send message to topic

Kind: instance method of StompServer

Param Type Description
topic string Destination for message
headers object Message headers
body string Message body

stompServer.frameSerializer(frame) ⇒ MsgFrame

Serialize frame to string for send

Kind: instance method of StompServer
Returns: MsgFrame - modified frame

Param Type Description
frame MsgFrame Message frame

stompServer.frameParser(frame) ⇒ MsgFrame

Parse frame to object for reading

Kind: instance method of StompServer
Returns: MsgFrame - modified frame

Param Type Description
frame MsgFrame Message frame

"error"

Client error event

Kind: event emitted by StompServer

"connecting"

Client connecting event, emitted after socket is opened.

Kind: event emitted by StompServer
Properties

Name Type
sessionId string

"connected"

Client connected event, emitted after connection established and negotiated

Kind: event emitted by StompServer
Properties

Name Type
sessionId string
headers object

"disconnected"

Client disconnected event

Kind: event emitted by StompServer
Properties

Name Type
sessionId string

"send"

Event emitted when broker send message to subscribers

Kind: event emitted by StompServer
Properties

Name Type Description
dest string Destination
frame string Message frame

"subscribe"

Client subscribe event, emitted when client subscribe topic

Kind: event emitted by StompServer
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

"unsubscribe"

Client subscribe event, emitted when client unsubscribe topic

Kind: event emitted by StompServer
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

ServerConfig : object

STOMP Server configuration

Kind: global typedef

Param Type Default Description
server http.Server Http server reference
[debug] function function(args) {} Debug function
[path] string "/stomp" Websocket path

OnSubscribedMessageCallback : function

Subscription callback method

Kind: global typedef

Param Type Description
msg string Message body
headers object Message headers
headers.destination string Message destination
headers.subscription string Id of subscription
headers.message-id string Id of message
headers.content-type string Content type
headers.content-length string Content length

MsgFrame : object

Message frame

Kind: global typedef

stompbrokerjs's People

Contributors

4ib3r avatar

Watchers

Nikolay Barbariyskiy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.