<commit_before>const debug = require('debug')('cardgames:socket');
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
// const games = {
//   war: {
//     players: {
//       max: 2,
//       min: 2
//     }
//   }
// };
const Rooms = new (require('./app/rooms.js'));

app.use(express.static(`${__dirname}/public`));

app.get('/', (req, res) => {
  res.sendFile(`${__dirname}/index.html`);
});

// TODO: Abstract this out to separate file(s?)
io.on('connection', (socket) => {
  debug(socket.id, 'connected');
  // TODO: Abstract connection out to player class
  // TODO: Figure out reconnection
  socket.on('create', (params) => {
    debug(socket.id, 'begin room creation', params.room);
    socket.name = params.name;  // Assign the socket the name provided by the game creator
    Rooms.create(socket, params); // Create the room inside the room manager
  });
  socket.on('join', (params) => {
    socket.name = params.name;
    Rooms.join(socket, params.code);
  });
  socket.on('shuffle', () => {
    console.log('shuffling');
    // TODO: figure out how to allow only shuffling of the current game
    // TODO: figure out how to allow only shuffling by the current dealer
  });
  socket.on('disconnecting', () => {
    console.log(socket.id, 'is about to disconnect');
    console.log(socket.rooms);
    // TODO: Check disconnecting users rooms; start destruction countdown if user count is zero upon current user leaving; promote other user to owner otherwise
  });
  socket.on('disconnect', () => {
    console.log(socket.id, 'disconnected!');
  });
});
<commit_msg>add init and leave events; remove disconnecting event<commit_after>const debug = require('debug')('cardgames:socket');
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
// const games = {
//   war: {
//     players: {
//       max: 2,
//       min: 2
//     }
//   }
// };
const Rooms = new (require('./app/rooms.js'));

app.use(express.static(`${__dirname}/public`));

app.get('/', (req, res) => {
  res.sendFile(`${__dirname}/index.html`);
});

// TODO: Abstract this out to separate file(s?)
io.on('connection', (socket) => {
  debug(socket.id, 'connected');
  // TODO: Abstract connection out to player class
  // TODO: Figure out reconnection
  socket.on('init', (data) => {
    debug(socket.id, 'named', data.name);
    socket.name = data.name;
  });
  socket.on('dude::bro', (data) => {
    console.log(data);
  });
  socket.on('create', (params) => {
    debug(socket.id, 'begin room creation', params.room);
    Rooms.create(socket, params); // Create the room inside the room manager
  });
  socket.on('join', (params) => {
    debug(socket.id, 'join room', params.code);
    Rooms.join(socket, params.code);
  });
  socket.on('leave', () => {
    console.log(socket.rooms);
  });
  socket.on('shuffle', () => {
    console.log('shuffling');
    // TODO: figure out how to allow only shuffling of the current game
    // TODO: figure out how to allow only shuffling by the current dealer
  });
  socket.on('disconnect', () => {
    console.log(socket.id, 'disconnected!');
  });
});

{'fraction_non_alphanumeric': 0.18842364532019704, 'fraction_numerical': 0.0012315270935960591, 'mean_word_length': 3.3964817320703653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '2413696', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1015, 'n_words': 273}