WAMP™ server in NodeJS
iowamp is a WAMP™ server in NodeJS. Currently it only supports basic RPC calls, but pub/sub support is coming. It attaches to WebSocket.IO.
WebSocket Application Messaging Protocol (WAMP) is a protocol for RPC & PubSub support, based on WebSockets. Technically, WAMP is an officially registered WebSocket subprotocol proposed by Tavendo.
Apache License (version 2)
iowamp itselfs requires version 0.6.x of NodeJS or higher. If you want to run the tests, you'll want Vows. To really use iowamp, you will also need WebSocket.IO.
npm install iowamp
Before you can start using iowamp in your project, you need to attach it to an websocket.io instance of your choice:
var iowamp = require'./lib'wsio = require'websocket.io';var server = wsiolisten8000;var app = iowampattachserver;
Registering a RPC class with some methods is also easy - here is an example for it:
var iowamp = require'./lib'wsio = require'websocket.io';var server = wsiolisten8000;var app = iowampattachserver;apprpc'#'thisregister'add'cbnull a + b;;;
The code should be kinda self-explanatory, allthough here is some additional information:
app.rpc(baseURI, constructor) registers a new RPC class
cb(error, result) Kinda self-explanatory. If an error will be passed, a generic error will be send back to the WAMP client. If not, the result will be send back.
If you want to catch methods which are unknown / not declared, you can listen for the unknownCall event:
appon'unknownCall'// Your code goes here;
iowamp NodeJS WAMP™ server - © 2012-2013 P. Mathis (firstname.lastname@example.org)