Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

socket.io-cap

2.0.3 • Public • Published

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');
  }
})

Install

npm i socket.io-cap

DownloadsWeekly Downloads

47

Version

2.0.3

License

MIT

Unpacked Size

6.83 kB

Total Files

4

Last publish

Collaborators

  • avatar