1.4.1 • Published 7 years ago

zdrowieton v1.4.1

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

Zdrowieton.MessagingClient

JS library providing websocket communication for Zdrowieton hackathon.

Build Status npm version

Information about the hackathon itself can be found here.

This simple library which enables websocket communication with server.

Installation

Just install it using NPM:

npm install zdrowieton

and then require it in your app:

var ZdrowietonMessagingClient = require('zdrowieton')

If you don't use a module bundler like Browserify or Wwebpack, then download this repo and include zdrowietonMessagingClient.js in your HTML file. Remember to include stomp-js dependency as well!

<script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.0.0/sockjs.min.js"></script>
<script src="zdrowietonMessagingClient.js"></script>`

Usage

First create an instance:

var mc = new ZdrowietonMessagingClient(config);

Where config is an configurartion with following keys:

Connecting

not required, subscribe and sendMessage automatically connects to server

mc.connect();

Subscribing to messaged:

mc.subscribe(topicName, function callback(message) { ... });

Sending messages:

mc.sendMessage(topicName, message);

A message can a string, Array or an Object, which will be serialized to JSON automatically

Unsubscribing:

mc.unsubscribe(topicName);

Closing connection:

mc.closeConnection();

Usage examples

Check example-browser.html or example-node.js for sample usage.

1.4.1

7 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago