<commit_before>var hapi = require('Hapi');
var io   = require('socket.io');

var server = new hapi.Server(9000, { cors: true });
var peerTable = {};


server.route({ 
  method: 'GET', path: '/', 
  handler: function (request, reply) { reply('Signaling Server'); }
});

server.start(hapiStarted);

function hapiStarted() {
  io.listen(server.listener).on('connection', ioConnectionHandler);
  console.log('Signaling Server Started');
}

function ioConnectionHandler(socket) {
  socket.on('s-request',  peerConnectRequest);
  socket.on('s-response', peerConnectResponse);
  socket.on('disconnect', peerRemove); // socket.io own event

  console.log('New peer connect with socket ID of: ', socket.id);
  peerTable[socket.id] = socket;

  function peerConnectRequest (peerInvite) {
    var peersAvailable = arePeersAvailable();
    if (!peersAvailable) {
      return socket.emit('c-response', {peersAvailable: peersAvailable});
    }

    peerInvite.ticket = {
      requester: socket.id,
      solicited: notSamePeer(socket.id)
    };
    
    peerTable[peerInvite.ticket.solicited].emit('c-request', peerInvite);
  }

  function peerConnectResponse (peerInvite) {
    peerTable[peerInvite.ticket.requester].emit('c-response', peerInvite);
  }

  function peerRemove() { 
    console.log('socket disconnect with ID: ', socket.id);      
    delete peerTable[socket.id];
  }
}

function arePeersAvailable() {
  if (Object.keys(peerTable).length > 1) {
    return true;
  }
  else {
    return false;
  }
}

function notSamePeer(id) {
  var peerIdList = Object.keys(peerTable);

  for (var i=0; peerIdList.length; i++) {
    if (peerIdList[i] !== id) {
      return peerIdList[i];
    } else {
      continue;
    }
  }
}

<commit_msg>add a more verbose start message<commit_after>var hapi = require('Hapi');
var io   = require('socket.io');

var server = new hapi.Server(parseInt(process.env.PORT) || 9000, { cors: true });
var peerTable = {};


server.route({ 
  method: 'GET', path: '/', 
  handler: function (request, reply) { reply('Signaling Server'); }
});

server.start(hapiStarted);

function hapiStarted() {
  io.listen(server.listener).on('connection', ioConnectionHandler);
  console.log('Signaling server has started on:', server.info.uri);
}

function ioConnectionHandler(socket) {
  socket.on('s-request',  peerConnectRequest);
  socket.on('s-response', peerConnectResponse);
  socket.on('disconnect', peerRemove); // socket.io own event

  console.log('New peer connect with socket ID of: ', socket.id);
  peerTable[socket.id] = socket;

  function peerConnectRequest (peerInvite) {
    var peersAvailable = arePeersAvailable();
    if (!peersAvailable) {
      return socket.emit('c-response', {peersAvailable: peersAvailable});
    }

    peerInvite.ticket = {
      requester: socket.id,
      solicited: notSamePeer(socket.id)
    };
    
    peerTable[peerInvite.ticket.solicited].emit('c-request', peerInvite);
  }

  function peerConnectResponse (peerInvite) {
    peerTable[peerInvite.ticket.requester].emit('c-response', peerInvite);
  }

  function peerRemove() { 
    console.log('socket disconnect with ID: ', socket.id);      
    delete peerTable[socket.id];
  }
}

function arePeersAvailable() {
  if (Object.keys(peerTable).length > 1) {
    return true;
  }
  else {
    return false;
  }
}

function notSamePeer(id) {
  var peerIdList = Object.keys(peerTable);

  for (var i=0; peerIdList.length; i++) {
    if (peerIdList[i] !== id) {
      return peerIdList[i];
    } else {
      continue;
    }
  }
}


{'fraction_non_alphanumeric': 0.14762443438914027, 'fraction_numerical': 0.003393665158371041, 'mean_word_length': 3.7732793522267207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3445111', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1140, 'n_words': 235}