Skip to content
/ wamp.js Public
forked from webee/wamp.js

The Web Application Messaging Protocol for js.

License

Notifications You must be signed in to change notification settings

mwsv/wamp.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wamp.js

The Web Application Messaging Protocol for js, works in browser and react-native.

This Project is ported from autobahn-js, I removed all it's depencies(crypto-js, when, ws, msgpack-lite), and transformed into es6 style code. My aim is to work in web browser(support WebSocket, Promise) as well as react-native. so only supports json protocol.

install

npm i -S wamp.js

API

now, wamp.js's API is the same as autobahn-js: autobahn-js API

// autobahn-js
var autobahn = require('autobahn');
new autobahn.Connection(...);

// wamp.js
import wamp = require('wamp.js');
new wamp.Connection(...);

NOTE && NEW

// note:
// !!default enable automatic reconnect if host is unreachable

// new APIs and constants.
wamp.debugOn();
wamp.debugOff();
wamp.WAMP_STATUS;
wamp.STATUS;


// add onstatuschange, this can replace onopen and onclose;
connection.onstatuschange(status, details);
// status-> STATUS.DISCONNECTED, details-><close details>
// status-> STATUS.CONNECTING, details->undefined
// status-> STATUS.CONNECTED, details-><onjoin details>
// status-> STATUS.CLOSED, details-><close details>


// add retry and networkOffline notify.
// 1. automatic reconnect is not useful as retry interval time get longer, when network resume online, you must wait.
// 2. as WebSocket in browser(at least chrome) does not close when turn off network,
//       but it cannot send or recevie msgs, so I want to close it manually.
connection.retry(); // initiate to reconnect.
connection.networkOffline(); // notify to close transport.

// add .ping() and .addOnpongListener(handler)
session.ping()
session.addOnponListener(handler)

About

The Web Application Messaging Protocol for js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%