Removing - from roomHash

This commit is contained in:
Artyom Abubakirov 2018-07-02 17:11:14 +05:00
parent 16bed36624
commit 808c8c48b2

View File

@ -55,12 +55,18 @@ server.listen(port, function() {
}); });
function minifyRoomHash(hash) {
let text = hash.replace(new RegExp('[^A-Z^a-z^0-9]', 'g'), '');
text += 'roomID';
return text.slice(0, 6);
}
/* /*
* Rooms related methods * Rooms related methods
*/ */
function getRoom(socket) { function getRoom(socket) {
var room = socket.room ? socket.room.slice(0, 6) : socket.room; var room = socket.room ? minifyRoomHash(socket.room) : socket.room;
if (rooms[room] === undefined) { if (rooms[room] === undefined) {
createRoom(room); createRoom(room);
} }
@ -165,7 +171,7 @@ io.on('connection', function(socket) {
}); });
socket.on('subscribeToStream', function (data){ socket.on('subscribeToStream', function (data){
joinRoom(socket, data ? data.slice(0, 6) : data); joinRoom(socket, data ? minifyRoomHash(data) : data);
var room = getRoom(socket); var room = getRoom(socket);
if (room.presenter) { if (room.presenter) {
socket.emit('streamStarted'); socket.emit('streamStarted');
@ -177,7 +183,7 @@ io.on('connection', function(socket) {
}); });
socket.on('joinRoom', function (data) { socket.on('joinRoom', function (data) {
joinRoom(socket, data ? data.slice(0, 6) : data) joinRoom(socket, data ? minifyRoomHash(data) : data)
}); });