Skip to content

A implementation of the CometD client library as an ES6 module.

Notifications You must be signed in to change notification settings

sbordet/cometd-es6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cometd-es6

A implementation of the CometD client library as an ES6 module.

This library does not include the Dojo or jQuery plugins, and as such, the long-poll and JSONP transports don't work out of the box. You can find the jQuery-based plugin at cometd-transport-jquery.

Usage

import { CometD, WebSocketTransport } from 'cometd';
import { CallbackPollingTransport, LongPollingTransport } from 'cometd-transport-jquery';

// Borrowed from https://github.com/cometd/cometd/blob/master/cometd-javascript/jquery/src/main/webapp/jquery/jquery.cometd.js#L93
// Registration order is important. Transports will be tried in the order they are added.
const cometd = new CometD();
if (window.WebSocket) {
  cometd.registerTransport('websocket', new WebSocketTransport());
}
cometd.registerTransport('long-polling', new LongPollingTransport());
cometd.registerTransport('callback-polling', new CallbackPollingTransport());

cometd.configure({ ... });
cometd.handshake();
cometd.publish('/channel', { ... });

Development

For the time being, I plan to track the official CometD implementation. Please send suggestions and bug reports their way unless they are obviously related to this port.

About

A implementation of the CometD client library as an ES6 module.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published