Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including wampa with all npm packages installed. Try it out:

var wampa = require("wampa")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

wampa v0.0.5

Bi-directional, evented, websocketed, JSON RPC. It's kinda like WAMP, but not really.

Wampa Build Status NPM

Bi-directional, evented, websocketed, JSON RPC.

It's kinda like WAMP, but not really.

And the name Wampa wasn't taken, so I jumped on it!

(insert pic of me riding a wampa)

The whole thing sits on top of the ws module and provides some sugar and a tiny bit of convenience for the RPC-ish stufff.


npm install wampa


npm test -or- mocha



var Wampa = require('wampa'),
    http = require('http');

var server = http.createServer();

var wampaServer = new Wampa.Server({ server: server, path: '/wampa' });

wampaServer.on('connection', function(socket) {

  // the #Client has exposed some fns to the #Server
  socket.on('expose', function(fns) {
    // run the ping() fn on the #Client'blargh!', 'honk!');

  // handle arbitrary events from the #Client
  socket.on('clientEvent', function(data) {
    console.log('got clientEvent: ', data);

  // expose a fn to the #Client
    serveBacon: function() {
      console.log('the client wants bacon!');




var Wampa = require('../wampa');

var socket = new Wampa.Client('http://localhost:8000/wampa');

socket.on('open', function() {

  // expose #Client fns to the #Server
    ping: function(data, datum) {
      // send an event back to the #Server
      socket.sendEvent('clientEvent', 'blargh!')
    pong: function(data) { console.log('pong!', data); }

  // run exposed #Server fns from the #client
  socket.on('expose', function() {
    console.log('server is exposed!');



See for the details of ws events.

  • Wampa.Server === ws.Server()
  • Wampa.Client === ws()
  • socket.on('expose', function([FnNames]) { });


  • Socket.expose({}) - Accepts an object of functions to expose to the connected socket.
  •<exposed fn> - Triggers exposed functions on the connected socket.
  • Socket.sendEvent('blargh'[, args ]) - Sends blargh event with optional args to connected socket.


Look in the examples/ folder to see the good stuff.



  • Fixed the failing tests


  • Started keeping track
  • Added rudimentary pub/sub
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free