Skip to content

Instantly share code, notes, and snippets.

@urish
Created July 6, 2016 21:31
Show Gist options
  • Save urish/4a79ad2a48ad68ae6cac6bd0bc4e881c to your computer and use it in GitHub Desktop.
Save urish/4a79ad2a48ad68ae6cac6bd0bc4e881c to your computer and use it in GitHub Desktop.
Firebase Proxy
// To use: npm install ws
'use strict';
var WebSocket = require('ws');
var WebSocketServer = WebSocket.Server;
var wss = new WebSocketServer({port: 5000});
wss.on('connection', function (ws) {
var clientWs = new WebSocket('wss://s-dal5-nss-22.firebaseio.com/.ws?v=5&ns=firebase-name', {protocolVersion: 8, origin: 'http://localhost'});
clientWs.on('message', function(data) {
console.log('server', data);
ws.send(data);
});
ws.on('message', function(data) {
console.log('client', data);
clientWs.send(data);
});
console.log('conn');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment