Created
April 27, 2015 08:09
-
-
Save ipernet/9f908aad8000132cd72c to your computer and use it in GitHub Desktop.
Demo Socket.io 1.x
This file contains hidden or 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 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