All Projects → JSteunou → Webstomp Client

JSteunou / Webstomp Client

Licence: apache-2.0
Stomp client over websocket for browsers

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Webstomp Client

rabbitmq-web-stomp-examples
www.rabbitmq.com/
Stars: ✭ 90 (-67.86%)
Mutual labels:  rabbitmq, websockets, stomp
Rabbitmq Web Stomp
Provides support for STOMP over WebSockets
Stars: ✭ 87 (-68.93%)
Mutual labels:  rabbitmq, websockets, stomp
Delphistompclient
STOMP client for Embarcadero Delphi and FreePascal.
Stars: ✭ 93 (-66.79%)
Mutual labels:  rabbitmq, stomp
Enqueue Dev
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro
Stars: ✭ 1,977 (+606.07%)
Mutual labels:  rabbitmq, stomp
Digital Restaurant
DDD. Event sourcing. CQRS. REST. Modular. Microservices. Kotlin. Spring. Axon platform. Apache Kafka. RabbitMQ
Stars: ✭ 222 (-20.71%)
Mutual labels:  rabbitmq, websockets
Stompjs
Javascript and Typescript Stomp client for Web browsers and node.js apps
Stars: ✭ 324 (+15.71%)
Mutual labels:  rabbitmq, stomp
Rabbitmq Server
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Stars: ✭ 9,064 (+3137.14%)
Mutual labels:  rabbitmq, stomp
Ng2 Stompjs
Angular 6 and 7 - Stomp service over Websockets
Stars: ✭ 170 (-39.29%)
Mutual labels:  rabbitmq, stomp
Spring Boot Examples
个人学习 SpringBoot2.x 写的一些示例程序,目前正在持续更新中.....
Stars: ✭ 159 (-43.21%)
Mutual labels:  rabbitmq, websockets
spring-websocket-angular6
Example for using Spring Websocket and Angular with Stomp Messaging
Stars: ✭ 18 (-93.57%)
Mutual labels:  websockets, stomp
spring-boot-chatrooms
Spring Boot chatroom with multiple rooms using STOMP over websockets.
Stars: ✭ 33 (-88.21%)
Mutual labels:  websockets, stomp
Spec
The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.
Stars: ✭ 1,860 (+564.29%)
Mutual labels:  websockets, stomp
Spring React Boilerplate
Boilerplate application to demonstrate how to wire up Spring, JWT Authentication, React, Redux and Websockets
Stars: ✭ 70 (-75%)
Mutual labels:  websockets, stomp
ng2-STOMP-Over-WebSocket
STOMP Over WebSocket service for angular2
Stars: ✭ 35 (-87.5%)
Mutual labels:  websockets, stomp
Enqueue Bundle
[READ-ONLY] Message queue bundle for Symfony. RabbitMQ, Amazon SQS, Redis, Service bus, Async events, RPC over MQ and a lot more
Stars: ✭ 233 (-16.79%)
Mutual labels:  rabbitmq, stomp
rabbitmq-stomp
RabbitMQ STOMP plugin
Stars: ✭ 49 (-82.5%)
Mutual labels:  rabbitmq, stomp
ng4-stompjs-demo
A sample using Angular4, Angular CLI and @stom/ng2-stompjs
Stars: ✭ 20 (-92.86%)
Mutual labels:  rabbitmq, stomp
Aiowebsocket
Async WebSocket Client. Advantage: Flexible Lighter and Faster
Stars: ✭ 263 (-6.07%)
Mutual labels:  websockets
Springboot Learn
🌹springboot常用框架整合示例,涉及多种网站监控,数据缓存,网络通信,持久层,权限管理,常用工具等
Stars: ✭ 270 (-3.57%)
Mutual labels:  rabbitmq
Flask Uwsgi Websocket
🔌 High-performance WebSockets for your Flask apps powered by uWSGI.
Stars: ✭ 259 (-7.5%)
Mutual labels:  websockets

webstomp-client

This library provides a stomp client for Web browsers and nodejs through Web Sockets.

Project Status

This is a fork of the original stomp-websocket re-written in ES6 and incorporate pending pull requests. All credits goes to the original authors: Jeff Mesnil & Jeff Lindsay.

Browsers support

Only ES5 compatible modern browsers are supported. If you need a websocket polyfill you can use sockjs

nodejs support

As nodejs does not have a WebSocket object like browsers have, you must choose a websocket client and use webstomp.over instead of webstomp.client. Choosing a good client is maybe the most difficult part:

Example

npm run example will open examples in browser and try to connect to RabbitMQ Web-Stomp default Web Sockets url. node run example/broadcast-node.js will run a dead simple nodejs example.

Use

npm install webstomp-client

Web browser old fashion style

<script type="text/javascript" src="node_modules/webstomp-client/dist/webstomp.min.js"></script>

webstomp will be a global variable.

CommonJS

var webstomp = require('webstomp-client');

ES6 modules

import webstomp from 'webstomp-client';

By default it will load dist/webstomp.js, but the npm package.json es6 entry point to the es6 src file if you prefer loading this version.

API

Jeff Mesnil stomp-websocket documentation is still a must read even if the API evolved a little

webstomp

client(url, [options])

Uses global WebSocket object for you to return a webstomp Client object.

url

Web Sockets endpoint url

options
  • protocols: default to ['v10.stomp', 'v11.stomp', 'v12.stomp']
  • binary: default to false. See binary section.
  • heartbeat: default to {incoming: 10000, outgoing: 10000}. You can provide false to cut it (recommended when the server is a SockJS server) or a definition object.
  • debug: default to true. Will log frame using console.log

over(ws, [options])

Takes a WebSocket alike object instance to return a webstomp Client object. Allows you to use another WebSocket object than the default one. 2 cases for this:

  • you do not want webstomp.client to create a default instance for you.
  • you are in an old browser or nodejs and do not have a global WebSocket object that webstomp.client can use.
ws

WebSocket object instance

options
  • binary: default to false. See binary section.
  • heartbeat: default to {incoming: 10000, outgoing: 10000}. You can provide false to cut it (recommended when the server is a SockJS server) or a definition object.
  • debug: default to true. Will log frame using console.log

VERSIONS

supportedVersions()

List all STOMP specifications supported.

supportedProtocols()

List all websocket STOMP protocols supported. Useful when creating your own WebSocket instance, although optional, protocols is often the second parameter.

Client

A client instance can and should be created through webstomp.client or webstomp.over

connect

  • connect(headers, connectCallback)
  • connect(headers, connectCallback, errorCallback)
  • connect(login, passcode, connectCallback)
  • connect(login, passcode, connectCallback, errorCallback)
  • connect(login, passcode, connectCallback, errorCallback, host)

disconnect(disconnectCallback, headers={})

send(destination, body='', headers={})

subscribe(destination, callback, headers={})

unsubscribe(id, header={})

It is preferable to unsubscribe from a subscription by calling unsubscribe() directly on the object returned by client.subscribe()

var subscription = client.subscribe(destination, onmessage);
...
subscription.unsubscribe(headers);

headers are optionals

onreceive(frame)

If defined on the client instance this function will be called whenever a message is received and in the absence of an explicit subscribe(). Some brokers (at least RabbitMQ) will setup an internal routing topology for RPC patterns when a message is sent with certain headers.

In RabbitMQ it's called Direct Reply-To

On the client

let onreceive(frame)=>{
        console.log('Message received',frame)
}

client.onreceive=onreceive

let headers = {
        'reply-to'  :'/temp-queue/webstomp',
}

client.send('/topic/public.echo.hi.mom','a message')

On the server (using Amqplib for example)

ch.publish('',raw_message.properties.replyTo,Buffer.from('a reply'))

begin([transaction])

If no transaction ID is passed, one will be created automatically

commit(transaction)

It is preferable to commit a transaction by calling commit() directly on the object returned by client.begin():

var tx = client.begin(txid);
...
tx.commit();

abort(transaction)

It is preferable to abort a transaction by calling abort() directly on the object returned by client.begin():

var tx = client.begin(txid);
...
tx.abort();

ack(messageID, subscription, headers={})

It is preferable to acknowledge a message by calling ack() directly on the message handled by a subscription callback:

client.subscribe(destination, (message) => {
        // process the message
        // acknowledge it
        message.ack();
    }, {'ack': 'client'}
);

nack(messageID, subscription, headers={})

It is preferable to nack a message by calling nack() directly on the message handled by a subscription callback:

client.subscribe(destination, (message) => {
        // process the message
        // acknowledge it
        message.nack();
    }, {'ack': 'client'}
);

debug

Will use console.log by default. Override it to update its behavior.

Binary

It is possible to use binary frame instead of string frame over Web Sockets.

  • client side: set the binary option to true.
  • server side: use a compatible websocket server, like with RabbitMQ Web-Stomp since 3.6

Heartbeat

Not all server are compatible, you may have to deactivate this feature depending the server you are using. For example RabbitMQ Web-Stomp is compatible only since 3.6 with native Web Sockets server.

Authors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].