Skip to content

Instantly share code, notes, and snippets.

@ipernet
Created April 27, 2015 08:09
Show Gist options
  • Save ipernet/9f908aad8000132cd72c to your computer and use it in GitHub Desktop.
Save ipernet/9f908aad8000132cd72c to your computer and use it in GitHub Desktop.
Demo Socket.io 1.x
var express = require('express'),
bodyParser = require('body-parser'),
app = express();
var httpServer = require('http')
.createServer(app)
.listen(config.listening_port, config.listening_address_http);
var httpServerWS = require('http')
.createServer()
.listen(config.listening_port, config.listening_address_ws);
/**
* App
*/
var io = require('socket.io')(httpServerWS, { path: config.socket_io_path });
io.on('connection', function(socket)
{
socket.emit('handshake');
socket.on('register', function(data)
{
});
});
// An application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false });
// Use the parser per route
app.post('/sources/updates', urlencodedParser, function(req, res)
{
res.send('Pushed');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment