# webstomp-client
This library provides a [stomp](https://stomp.github.io/) client for Web browsers and nodejs through Web Sockets.
## Project Status
This is a fork of the original [stomp-websocket](https://github.com/jmesnil/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](http://sockjs.org)
## nodejs support
As nodejs does not have a WebSocket object like browsers have, you must choose a websocket client and use [webstomp.over](https://github.com/JSteunou/webstomp-client#overws-options) instead of `webstomp.client`. Choosing a good client is maybe the most difficult part:
* [websocket](https://www.npmjs.com/package/websocket)
* [ws](https://www.npmjs.com/package/ws)
* [sockjs](https://www.npmjs.com/package/sockjs-client) If your server part is also SockJS
* ... add yours
## Example
`npm run example` will open examples in browser and try to connect to [RabbitMQ Web-Stomp](https://www.rabbitmq.com/web-stomp.html) 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
```html
```
`webstomp` will be a global variable.
### CommonJS
```js
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](http://jmesnil.net/stomp-websocket/doc/) is still a must read even if the API [evolved](CHANGELOG.md) a little
### webstomp
#### client(url, [options])
Uses global `WebSocket` object for you to return a webstomp `Client` object.
##### url
Web Sockets endpoint url
##### options