var socketio = require('socket.io')

var SocketServer = function(server) {
  this.server = server;
}

SocketServer.prototype.emit = function(data) {
  var dataObj = { 'data': data };
  this.server.sockets.emit('irdata', dataObj);
  console.log("data emitted: " + data);
}

function start(httpServer) {
  var server = socketio.listen(httpServer);
  return new SocketServer(server);
}

function socketHandler(socket) {
  socket.emit('alert', { data : 'socket alert event' });
  socket.on('log', function(data) { console.log(data) });
}

exports.start = start;