WAMP Implementation
WAMP lightweight implementation for both browser and server-side (with ws npm package).
cjs-wamp
extends Emitter interface.
It does not create any WebSocket connections but uses an existing one.
Installation
npm install cjs-wamp
Usage
Add the constructor to the scope:
var Wamp = ;
Create an instance from some existing WebSocket connection:
var ws = 'ws://echo.websocket.org' wamp = ws;
Send message to execute remotely:
wamp;
Serve remote request:
wamp;
Send notification with some optional data:
wamp;
Serve received notification:
wamp;
Original WebSocket connection is also available:
wampsocket;
Catch the moment when WebSocket connection is ready:
wampsocket { // send or receive messages here};
Server-side example with ws npm package:
var server = new Serverport: 9000 Wamp = ; server;
Error codes
Value | Message | Description |
---|---|---|
-32700 | Parse error | Invalid JSON data was received. |
-32600 | Invalid Request | The JSON sent is not a valid Request object. |
-32601 | Method not found | The method does not exist / is not available. |
Contribution
If you have any problems or suggestions please open an issue according to the contribution rules.
License
cjs-wamp
is released under the MIT License.