Skip to content

EltonZhong/socket.io-proxy-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socket.io-proxy-server

What a elegant way to proxy and intercept from socket.io connections!!!

inspired by http-proxy

Usage:

Using with Node http server

process.env['SERVER'] = 'https://the_target_socket_io_server..';
const app = require('http').createServer(handler)
const proxy = require('socket.io-proxy-server')(app);
const manager = proxy(http);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify request here...
    }
);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify response here...
    }
);

Or with koa:

const Koa = require('koa');
const app = new Koa();
const http = require('http').createServer(app.callback());
const port = process.env.PORT || 3000;

const proxy = require('socket.io-proxy-server');
const manager = proxy(http);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify request here...
    }
);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify response here...
    }
);

About

đŸ„Proxy & intercepter for socket.io.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published