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 socket.io-cap with all npm packages installed. Try it out:

var socketIoCap = require("socket.io-cap")

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

socket.io-cap v2.0.2

Proxy server for capturing and modifying socket.io data

socket.io-cap

Proxy server for capturing and modifying socket.io data.

Installation

npm install socket.io-cap

Example

const proxy = require('socket.io-cap').createProxy().listen(8889);
proxy.showAll();
const proxy = require('socket.io-cap').createProxy({/*options*/});
proxy.listen(8889);

proxy.on('conn', ctx => {
  proxy.showHeader(ctx);
  ctx.headers.referer = 'http://example.com';
});

proxy.on('packet', (p, {cSocket, pSocket}) => {
  proxy.showPacket(p, false);

  if (p.event == 'my-message') {
    p.args[0] = 'hello world';
  }

  if (p.event == 'test' && p.fromServer) {
    p.drop = true;
    cSocket.emit('custom-message', 'hello world');
  }
})

Metadata

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