Skip to content

Instantly share code, notes, and snippets.

@rockos
Created February 26, 2013 05:27
Show Gist options
  • Save rockos/5036138 to your computer and use it in GitHub Desktop.
Save rockos/5036138 to your computer and use it in GitHub Desktop.
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