<commit_before>/**
 * io.js
 *
 * Description:
 *  file for WebSocket
 *
 * Author:
 *  sota1235
 */

var socket = require('socket.io');

module.exports = function(server) {
  var io = socket.listen(server);

  io.on('connection', function(socket) {
    console.log('a user connected');

    // send comment
    socket.on('comment', function(msg) {
      console.log('comment: ' + msg);
      io.emit('comment', msg);
    });
    // send vote for choices of quiz
    socket.on('vote', function(msg) {
      console.log('vote: ' + msg);
      io.emit('vote', msg);
    });
    // display quiz
    socket.on('open', function(id, text) {
      console.log('open: ' + id);
      io.emit('open', id);
      io.emit('question-open', text); // index page
    });
    // answer check (count vote)
    socket.on('answerCheck', function(msg) {
      console.log('answer check!');
      io.emit('answerCheck');
    });
    // show answer
    socket.on('openAnswer', function(msg) {
      console.log('open answer: ' + (msg + 1));
      io.emit('openAnswer', msg);
    });
    // hide quiz
    socket.on('finish', function(msg) {
      console.log('finish quiz');
      io.emit('finish');
      io.emit('question-finish'); // index page
    });
    // quiz timer finish
    socket.on('timerFinish', function(msg) {
      console.log('exit time limit of quiz');
      io.emit('timerFinish');
    });
  });
};<commit_msg>modify: add new socket handler on server side<commit_after>/**
 * io.js
 *
 * Description:
 *  file for WebSocket
 *
 * Author:
 *  sota1235
 */

var socket = require('socket.io');

module.exports = function(server) {
  var io = socket.listen(server);

  io.on('connection', function(socket) {
    console.log('a user connected');

    // send comment
    socket.on('comment', function(msg) {
      console.log('comment: ' + msg);
      io.emit('comment', msg);
    });
    // send vote for choices of quiz
    socket.on('vote', function(msg) {
      console.log('vote: ' + msg);
      io.emit('vote', msg);
    });
    // display quiz
    socket.on('open', function(id, text) {
      console.log('open: ' + id);
      io.emit('open', id);
      io.emit('question-open', text); // index page
    });
    // answer check (count vote)
    socket.on('answerCheck', function(msg) {
      console.log('answer check!');
      io.emit('answerCheck');
    });
    // show answer
    socket.on('openAnswer', function(msg) {
      console.log('open answer: ' + (msg + 1));
      io.emit('openAnswer', msg);
    });
    // hide quiz
    socket.on('finish', function(msg) {
      console.log('finish quiz');
      io.emit('finish');
      io.emit('question-finish'); // index page
    });
    // quiz timer finish
    socket.on('timerFinish', function(msg) {
      console.log('exit time limit of quiz');
      io.emit('timerFinish');
    });
    // publish image events
    socket.on('imageEvent', function(msg) {
      console.log('send image event: ' + msg);
      io.emit('imageEvent', msg);
    });
  });
};
{'fraction_non_alphanumeric': 0.18722979714000665, 'fraction_numerical': 0.0033255736614566014, 'mean_word_length': 2.568208778173191, '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': '3027715', 'n_tokens_mistral': 972, 'n_tokens_neox': 941, 'n_words': 206}