From 580ef5a65266571b3964a4addf6a8d9d818a48e9 Mon Sep 17 00:00:00 2001 From: Ilshat Safiullin Date: Thu, 21 Jun 2018 08:39:18 +0500 Subject: [PATCH] Short room hashes --- server.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index ce8eda6..ab655ab 100755 --- a/server.js +++ b/server.js @@ -60,10 +60,11 @@ server.listen(port, function() { */ function getRoom(socket) { - if (rooms[socket.room] === undefined) { - createRoom(socket.room); + var room = socket.room ? socket.room.slice(0, 6) : socket.room; + if (rooms[room] === undefined) { + createRoom(room); } - return rooms[socket.room]; + return rooms[room]; } function createRoom(room) { @@ -164,15 +165,15 @@ io.on('connection', function(socket) { }); socket.on('subscribeToStream', function (data){ - joinRoom(socket, data); + joinRoom(socket, data ? data.slice(0, 6) : data); var room = getRoom(socket); if (room.presenter) { socket.emit('streamStarted'); } }); - socket.on('joinRoom', function (data){ - joinRoom(socket, data) + socket.on('joinRoom', function (data) { + joinRoom(socket, data ? data.slice(0, 6) : data) });