<commit_before>var io = require('socket.io').listen(11097);

io.sockets.on('connection', function (socket) {
  socket.joinedChannels = [];

  socket.on('getChan',function(obj){
    console.log('hello getChan request', obj);
    var chanId = "" + Math.floor(Math.random() * 10000000);
    socket.emit('chanId', chanId);
    socket.join(chanId);
  });

  socket.on('broadcast', function(obj){
    socket.broadcast.to(obj.id).emit('broadcast', obj); //dont send back to self
    if(this.request){
      this.resultCB('ok');
    }
  });

  socket.on('joinChannel', function(id){
    if(socket.joinedChannels.length < 5){
      socket.join(id);
      socket.joinedChannels.push(id);
      socket.emit('joined', id);
    }
  });
});<commit_msg>use socket.io room manager instead of special array<commit_after>var io = require('socket.io').listen(11097);

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

  socket.on('getChan',function(obj){
    console.log('hello getChan request', obj);
    var chanId = "" + Math.floor(Math.random() * 10000000);
    socket.emit('chanId', chanId);
    socket.join(chanId);
  });

  socket.on('broadcast', function(obj){
    socket.broadcast.to(obj.id).emit('broadcast', obj); //dont send back to self
  });

  socket.on('joinChannel', function(id){
    var roomsJoined = Object.keys(io.sockets.manager.roomClients[socket.id]);
    if(roomsJoined.length < 5){
      socket.join(id);
      socket.emit('joined', id);
    }
  });
});
{'fraction_non_alphanumeric': 0.1864290610006854, 'fraction_numerical': 0.019191226867717615, 'mean_word_length': 3.8504983388704317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6007478', 'n_tokens_mistral': 524, 'n_tokens_neox': 487, 'n_words': 82}