Created
February 26, 2013 05:27
-
-
Save rockos/5036138 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 HOST = '127.0.0.1'; | |
var PORT = 3011; | |
function log(objs) { | |
var d = new Date, | |
fmtDate = '', | |
month; | |
var msg = {}; | |
month = d.getMonth() + 1; | |
fmtDate = d.getFullYear() + '/' + month + '/' + d.getDate() + | |
' ' + d.getHours() + ':' + d.getMinutes() + ':' + | |
d.getSeconds() + ':' + d.getMilliseconds(); | |
console.log(fmtDate + ' ' + objs.title+':'+objs.info); | |
} | |
/** | |
* | |
*/ | |
var ws = require('websocket.io').listen(PORT); | |
ws.on('connection', function(socket){ | |
log({'title':'socket','info':'bound on '+PORT}); | |
socket.on('message', function(data){ | |
log({'title':'socket','info':data}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment