3.1.2 • Published 6 years ago

@statflo/socket v3.1.2

Weekly downloads
26
License
MIT
Repository
github
Last release
6 years ago

@statflo/socket

A promised StompJS and SockJS class for managing subscriptions easily.

Usage

import SocketService from '@statflo/socket';

const service = new SocketService('http://foo.bar/live', { connectHeader: 'foobar' }); // where { connectHeader } is an instance of Stomp.StompHeaders

service.connect()
    .then(frame => {
        console.log(frame);
    })
    .catch(error => {
        console.error(error);
    });

Subscription

const exchange = service.subscribe('foo/bar', function(message) {
    console.log(message);
});
exchange.unsubscribe('foo/bar');

Messaging

service.message('foo/bar', 'Hello world!');

License

MIT Statflo Inc.