<commit_before>/* globals */

'use strict';

module.exports = function (app, data, controllerLoaders) {
  const server = require('http').Server(app);
  const io = require('socket.io').listen(server);

  const {
    messageControllerLoader
  } = controllerLoaders;

  const {
    messageData
  } = data;

  let messageController = false;
  var messagesToDisplay;

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

    var sendStatus = function (status) {
      socket.emit('status', status);
    };

    if (!messageController) {
      messageController = messageControllerLoader(messageData);
    }

    messageController.getLast100Messages()
      .then((messages) => {
        // console.log(messages);
        // messages.toArray(function (err, res) {
        //   socket.emit('output', res);
        // });
      });

    // col.find().limit(100).sort({
    //   _id: 1
    // }).toArray(function (err, res) {
    //   socket.emit('output', res);
    // });

    socket.on('input', function (socketData) {<commit_msg>Add history to chat<commit_after>/* globals */

'use strict';

module.exports = function (app, data, controllerLoaders) {
  const server = require('http').Server(app);
  const io = require('socket.io').listen(server);

  const {
    messageControllerLoader
  } = controllerLoaders;

  const {
    messageData
  } = data;

  let messageController = false;
  var messagesToDisplay;

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

    var sendStatus = function (status) {
      socket.emit('status', status);
    };

    if (!messageController) {
      messageController = messageControllerLoader(messageData);
    }

    messageController.getLast100Messages()
      .then((messages) => {
        socket.emit('output', messages);
      });

    socket.on('input', function (socketData) {
{'fraction_non_alphanumeric': 0.14994425863991082, 'fraction_numerical': 0.005574136008918618, 'mean_word_length': 2.997772828507795, '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': '1827241', 'n_tokens_mistral': 539, 'n_tokens_neox': 514, 'n_words': 107}