diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm index 4112f25..58693eb 100644 --- a/lib/Vroom/I18N/en.pm +++ b/lib/Vroom/I18N/en.pm @@ -104,6 +104,12 @@ our %Lexicon = ( "KICKED" => "Kicked", "YOU_HAVE_BEEN_KICKED" => "You've been kicked out of the room", "AN_ADMIN_HAS_KICKED_YOU" => "An administrator of the room has excluded you", + "YOU_HAVE_MUTED_s" => "You have muted %s's microphone", + "CANT_MUTE_OWNER" => "You can't mute the microphone of this participant", + "YOU_HAVE_SUSPENDED_s" => "You have suspended %s's webcam", + "CANT_SUSPEND_OWNER" => "You can't suspend this participant's webcam", + "YOU_HAVE_KICKED_s" => "You have kicked %s out of the room", + "CANT_KICK_OWNER" => "You can't kick this participant out of the room", "MIC_MUTED" => "Your microphone is now muted", "MIC_UNMUTED" => "Your microphone is now unmuted", "CAM_SUSPENDED" => "Your webcam is now suspended", diff --git a/lib/Vroom/I18N/fr.pm b/lib/Vroom/I18N/fr.pm index 3cfda06..ec18be8 100644 --- a/lib/Vroom/I18N/fr.pm +++ b/lib/Vroom/I18N/fr.pm @@ -110,6 +110,12 @@ our %Lexicon = ( "KICKED" => "Éjecté", "YOU_HAVE_BEEN_KICKED" => "Vous avez été éjecté du salon", "AN_ADMIN_HAS_KICKED_YOU" => "Un administrateur du salon vous a exclus", + "YOU_HAVE_MUTED_s" => "Vous avez coupé le micro de %s", + "CANT_MUTE_OWNER" => "Vous ne pouvez pas couper le micro de ce participant", + "YOU_HAVE_SUSPENDED_s" => "Vous avez mis la webcam de %s en pause", + "CANT_SUSPEND_OWNER" => "Vous ne pouvez pas mettre la webcam de ce participant en pause", + "YOU_HAVE_KICKED_s" => "Vous avez bani %s du salon", + "CANT_KICK_OWNER" => "Vous ne pouvez pas bannir ce participant", "MIC_MUTED" => "Votre micro est coupé", "MIC_UNMUTED" => "Votre micro est à nouveau actif", "CAM_SUSPENDED" => "Votre webcam est en pause", diff --git a/public/js/vroom.js b/public/js/vroom.js index 94075a6..67b939f 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -43,7 +43,13 @@ var locale = { s_IS_KICKING_s: '', MUTE_PEER: '', SUSPEND_PEER: '', - KICK_PEER: '' + KICK_PEER: '', + YOU_HAVE_MUTED_s: '', + CANT_MUTE_OWNER: '', + YOU_HAVE_SUSPENDED_s: '', + CANT_SUSPEND_OWNER: '', + YOU_HAVE_KICKED_s: '', + CANT_KICK_OWNER: '' }; // Localize the strings we need @@ -430,22 +436,40 @@ function initVroom(room) { // Mute a peer function mutePeer(id){ - webrtc.sendToAll('owner_mute', {peer: id}); + if (peers[id] && peers[id].role != 'owner'){ + webrtc.sendToAll('owner_mute', {peer: id}); + $.notify(sprintf(locale.YOU_HAVE_MUTED_s, peers[id].displayName), 'info'); + } + else{ + $.notify(locale.CANT_MUTE_OWNER, 'error'); + } } // Puase a peer function pausePeer(id){ - webrtc.sendToAll('owner_pause', {peer: id}); + if (peers[id] && peers[id].role != 'owner'){ + webrtc.sendToAll('owner_pause', {peer: id}); + $.notify(sprintf(locale.YOU_HAVE_SUSPENDED_s, peers[id].displayName), 'info'); + } + else{ + $.notify(locale.CANT_SUSPEND_OWNER, 'error'); + } } // Kick a peer function kickPeer(id){ - webrtc.sendToAll('owner_kick', {peer: id}); - // Wait a bit for the peer to leave, but end connection if it's still here - // after 2 seconds - setTimeout(function(){ - if (peers[id]){ - peers[id].obj.end(); - } - }, 2000); + if (peers[id] && peers[id].role != 'owner'){ + webrtc.sendToAll('owner_kick', {peer: id}); + // Wait a bit for the peer to leave, but end connection if it's still here + // after 2 seconds + setTimeout(function(){ + if (peers[id]){ + peers[id].obj.end(); + } + }, 2000); + $.notify(sprintf(locale.YOU_HAVE_KICKED_s, peers[id].displayName), 'info'); + } + else{ + $.notify(locale.CANT_KICK_OWNER, 'error'); + } } // Mute our mic @@ -475,7 +499,7 @@ function initVroom(room) { if (peers[data.id].role != 'owner'){ return; } - if (data.payload.peer && data.payload.peer == peers.local.id){ + if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ // Ignore this if the remote peer isn't the owner of the room if (!peers.local.micMuted){ muteMic(); @@ -484,7 +508,7 @@ function initVroom(room) { $.notify(sprintf(locale.s_IS_MUTING_YOU, peers[data.id].displayName), 'info'); } } - else{ + else if (data.payload.peer != peers.local.id){ $.notify(sprintf(locale.s_IS_MUTING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); } }); @@ -493,7 +517,7 @@ function initVroom(room) { if (peers[data.id].role != 'owner'){ return; } - if (data.payload.peer && data.payload.peer == peers.local.id){ + if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ if (!peers.local.paused){ suspendCam(); $("#suspendCamLabel").addClass('btn-danger active'); @@ -501,7 +525,7 @@ function initVroom(room) { $.notify(sprintf(locale.s_IS_SUSPENDING_YOU, peers[data.id].displayName), 'info'); } } - else{ + else if (data.payload.peer != peers.local.id){ $.notify(sprintf(locale.s_IS_SUSPENDING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); } }); @@ -510,11 +534,11 @@ function initVroom(room) { if (peers[data.id].role != 'owner'){ return; } - if (data.payload.peer && data.payload.peer == peers.local.id){ + if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ hangupCall; window.location.assign(rootUrl + 'kicked/' + roomName); } - else{ + else if (data.payload.peer != peers.local.id && peers[data.payload.peer] && peers[data.payload.peer].role != 'owner'){ $.notify(sprintf(locale.s_IS_KICKING_s, peers[data.id].displayName, peers[data.payload.peer].displayName), 'info'); // Wait a bit for the peer to leave, but end connection if it's still here // after 2 seconds