<commit_before>var _ = require('underscore');
var app = require('http').createServer();
var io = require('socket.io').listen(app);

var game = {
  status: 'waiting', // waiting | playing
  players: [], // player names
  stage: undefined, // stage name
  max: 2, // max nb of players
  turn: {
    actions: ['move', 'use', 'push'],
    player: undefined,
  },
};

var rooms = {
  lobby: [],
};

io.sockets.on('connection', function (socket) {

  socket.on('game:init', function (client) {
    socket.emit('players', rooms.lobby);
  });

  socket.on('game:start', function (options) {
    console.log(options);
  });

  socket.on('player:create', function (playerName) {
    rooms.lobby.push(playerName);
    socket.set('playerName', playerName);
    socket.join('lobby');
    io.sockets.in('lobby').emit('players', rooms.lobby);
    console.log(_(rooms).keys());
  });

});

app.listen(9001);<commit_msg>added game:host, game:join and game:created events to the game server<commit_after>var _ = require('underscore');
var app = require('http').createServer();
var io = require('socket.io').listen(app);

var GAME = {
  status: 'waiting', // waiting | playing
  players: [], // player names
  stage: undefined, // stage name
  max: 2, // max nb of players
  turn: {
    actions: ['move', 'use', 'push'],
    player: undefined,
  },
};

var rooms = {
  lobby: [],
};

io.sockets.on('connection', function (socket) {

  socket.on('game:init', function (client) {
    socket.emit('players', rooms.lobby);
  });

  socket.on('game:start', function (options) {
    console.log(options);
  });

  socket.on('player:create', function (playerName) {
    rooms.lobby.push(playerName);
    socket.set('playerName', playerName);
    socket.join('lobby');
    io.sockets.in('lobby').emit('players', rooms.lobby);
    console.log(_(rooms).keys());
  });

  socket.on('game:host', function (options) {
    socket.emit('game:create', options);
    console.log('game hosted', options);
  });

  socket.on('game:created', function (options) {
    rooms[options.name] = options;
    console.log('game created', options);
  });

  socket.on('game:join', function (options) { 
    console.log('join game:', options);
  });

});

app.listen(9001);
{'fraction_non_alphanumeric': 0.1991906474820144, 'fraction_numerical': 0.0044964028776978415, 'mean_word_length': 3.89010989010989, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4952699', 'n_tokens_mistral': 749, 'n_tokens_neox': 734, 'n_words': 150}