Created
May 24, 2013 22:06
-
-
Save fritz-gerneth/5646825 to your computer and use it in GitHub Desktop.
Extremy simple DDP-Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var sockjs = require('sockjs'); | |
var WebSocket = require('ws'); | |
var proxy = sockjs.createServer(); | |
proxy.on('connection', function(conn) { | |
var client = new WebSocket('ws://192.168.178.59:3000/sockjs/websocket'); | |
client.on('open', function() { | |
console.log('Proxy -> Server', 'connected'); | |
}); | |
client.on('message', function(data, flags) { | |
console.log('Server -> Proxy', data); | |
conn.write(data); | |
}); | |
conn.on('data', function(message) { | |
console.log('Client -> Proxy', message); | |
client.send(message); | |
}); | |
conn.on('close', function() { | |
client.close(); | |
}); | |
}); | |
var server = http.createServer(); | |
proxy.installHandlers(server, {prefix:'/sockjs', log: function () {}}); | |
server.listen(4000, '0.0.0.0'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment