diff --git a/app/src/Server.js b/app/src/Server.js index 8a136f6b..4221c476 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -455,12 +455,12 @@ io.on('connection', (socket) => { socket.room_id = room_id; if (roomList.has(socket.room_id)) { - callback('already exists'); + callback({ error: 'already exists' }); } else { log.debug('Created room', { room_id: socket.room_id }); let worker = await getMediasoupWorker(); roomList.set(socket.room_id, new Room(socket.room_id, worker, io)); - callback(socket.room_id); + callback({ room_id: socket.room_id }); } }); @@ -790,8 +790,9 @@ io.on('connection', (socket) => { if (json) { return { peer_name: - roomList.get(socket.room_id) && - roomList.get(socket.room_id).getPeers().get(socket.id).peer_info.peer_name, + (roomList.get(socket.room_id) && + roomList.get(socket.room_id).getPeers().get(socket.id).peer_info.peer_name) || + undefined, }; } return ( diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index 88320c4f..3849ab4b 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -2419,15 +2419,25 @@ class RoomClient { userLog('info', 'No participants detected', 'top-end'); return; } - // send some metadata about our file to peers in the room - this.socket.emit('fileInfo', { + let fileInfo = { peer_id: peer_id, broadcast: broadcast, peer_name: this.peer_name, fileName: this.fileToSend.name, fileSize: this.fileToSend.size, fileType: this.fileToSend.type, - }); + }; + this.appendMessage( + 'right', + this.rightMsgAvatar, + this.peer_name, + this.peer_id, + 'Send File: \n' + this.toHtmlJson(fileInfo), + 'all', + 'all', + ); + // send some metadata about our file to peers in the room + this.socket.emit('fileInfo', fileInfo); setTimeout(() => { this.sendFileData(peer_id, broadcast); }, 1000); @@ -2453,6 +2463,15 @@ class RoomClient { html.newline + ' File size: ' + this.bytesToSize(this.incomingFileInfo.fileSize); + this.appendMessage( + 'left', + this.leftMsgAvatar, + this.incomingFileInfo.peer_name, + this.incomingFileInfo.peer_id, + 'Receive File: \n' + this.toHtmlJson(this.incomingFileInfo), + 'all', + 'all', + ); receiveFileInfo.innerHTML = fileToReceiveInfo; receiveFileDiv.style.display = 'inline'; receiveProgress.max = this.incomingFileInfo.fileSize; @@ -2642,6 +2661,10 @@ class RoomClient { return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i]; } + toHtmlJson(obj) { + return '
' + JSON.stringify(obj, null, 4) + ''; + } + // #################################################### // SHARE VIDEO YOUTUBE - MP4 - WEBM - OGG or AUDIO mp3 // ####################################################