Last active
December 26, 2015 18:39
-
-
Save stetro/7196484 to your computer and use it in GitHub Desktop.
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 express = require('express'); | |
var routes = require('./routes'); | |
var http = require('http'); | |
var path = require('path'); | |
var socketio = require('socket.io'); | |
var crypto = require('crypto'); | |
var app = express(); | |
var expressserver = http.createServer(app).listen(app.get('port'), function() { | |
console.log('Express server listening on port ' + app.get('port')); | |
}); | |
var websocket = socketio.listen(expressserver); | |
websocket.sockets.on('connection', function(socket) { | |
var hash = generateUniqueHash(); | |
socket.on('collectShipData', function(data) { | |
data.name = hash; | |
websocket.sockets.emit('recieveShipData', data); | |
}); | |
socket.on('disconnect', function() { | |
websocket.sockets.emit('disconnectShipData', hash); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment