Web Application Messaging Protocol Implementation
WAMP lightweight implementation for both browser and server-side (with ws npm package).
wampi
extends Emitter interface.
It does not create any WebSocket connections but uses existing one.
Installation
npm install wampi
Usage
Add the constructor to the scope:
var Wampi = ;
Create an instance from some existing WebSocket connection:
var ws = 'ws://echo.websocket.org' wampi = ws;
Send message to execute remotely:
wampi;
Serve remote request:
wampi;
Send notification with some optional data:
wampi;
Serve received notification:
wampi;
Catch the moment when WebSocket connection is ready:
wampisocket { // send or receive messages here};
Server-side example with ws npm package:
var server = 'ws' Wampi = ; 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. |
Contribution
If you have any problem or suggestion please open an issue here. Pull requests are welcomed with respect to the JavaScript Code Style.
License
wampi
is released under the GPL-3.0 License.