Fix owner's action mess when a peer shares its screen

master
Daniel Berteaud 11 years ago
parent a1ad41d7d1
commit a6566704ff
  1. 2
      public/js/simplewebrtc.bundle.js
  2. 44
      public/js/vroom.js

@ -5148,7 +5148,7 @@ Peer.prototype.handleMessage = function (message) {
} else if (message.type === 'unmute') { } else if (message.type === 'unmute') {
this.parent.emit('unmute', {id: message.from, name: message.payload.name}); this.parent.emit('unmute', {id: message.from, name: message.payload.name});
} else { } else {
this.parent.emit(message.type, {id: message.from, payload: message.payload}); this.parent.emit(message.type, {id: message.from, payload: message.payload, roomType: message.roomType});
} }
}; };

@ -568,11 +568,12 @@ function initVroom(room) {
// An owner is muting/unmuting ourself // An owner is muting/unmuting ourself
webrtc.on('owner_toggle_mute', function(data){ webrtc.on('owner_toggle_mute', function(data){
if (peers[data.id].role != 'owner'){ // Ignore this if the remote peer isn't the owner of the room
// or if the peer receiving it is our local screen
if (peers[data.id].role != 'owner' || data.roomType == 'screen'){
return; return;
} }
if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ 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){ if (!peers.local.micMuted){
muteMic(); muteMic();
$('#muteMicLabel').addClass('btn-danger active'); $('#muteMicLabel').addClass('btn-danger active');
@ -597,7 +598,7 @@ function initVroom(room) {
}); });
// An owner is pausing/resuming our webcam // An owner is pausing/resuming our webcam
webrtc.on('owner_toggle_pause', function(data){ webrtc.on('owner_toggle_pause', function(data){
if (peers[data.id].role != 'owner'){ if (peers[data.id].role != 'owner' || data.roomType == 'screen'){
return; return;
} }
if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){
@ -625,7 +626,7 @@ function initVroom(room) {
}); });
// An owner is kicking us from the room // An owner is kicking us from the room
webrtc.on('owner_kick', function(data){ webrtc.on('owner_kick', function(data){
if (peers[data.id].role != 'owner'){ if (peers[data.id].role != 'owner' || data.roomType == 'screen'){
return; return;
} }
if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){
@ -760,12 +761,15 @@ function initVroom(room) {
// This peer claims he changed its role (usually from participant to owner) // This peer claims he changed its role (usually from participant to owner)
// Lets check this // Lets check this
webrtc.on('role_change', function(data){ webrtc.on('role_change', function(data){
if (data.roomType == 'screen'){
return;
}
getPeerRole(data.id); getPeerRole(data.id);
}); });
// A new notified email has been added // A new notified email has been added
webrtc.on('notif_change', function(data){ webrtc.on('notif_change', function(data){
if (peers.local.role != 'owner'){ if (peers.local.role != 'owner' || data.roomType == 'screen'){
return; return;
} }
$('#emailNotificationList > li').remove(); $('#emailNotificationList > li').remove();
@ -792,22 +796,37 @@ function initVroom(room) {
// A few notif on password set/unset or lock/unlock // A few notif on password set/unset or lock/unlock
webrtc.on('room_locked', function(data){ webrtc.on('room_locked', function(data){
if (data.roomType == 'screen'){
return;
}
$('#lockLabel').addClass('btn-danger active'); $('#lockLabel').addClass('btn-danger active');
$('#lockButton').prop('checked', true); $('#lockButton').prop('checked', true);
$.notify(sprintf(locale.ROOM_LOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info'); $.notify(sprintf(locale.ROOM_LOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info');
}); });
webrtc.on('room_unlocked', function(data){ webrtc.on('room_unlocked', function(data){
if (data.roomType == 'screen'){
return;
}
$('#lockLabel').removeClass('btn-danger active'); $('#lockLabel').removeClass('btn-danger active');
$('#lockButton').prop('checked', false); $('#lockButton').prop('checked', false);
$.notify(sprintf(locale.ROOM_UNLOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info'); $.notify(sprintf(locale.ROOM_UNLOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info');
}); });
webrtc.on('password_protect_on', function(data){ webrtc.on('password_protect_on', function(data){
if (data.roomType == 'screen'){
return;
}
$.notify(sprintf(locale.PASSWORD_PROTECT_ON_BY_s, stringEscape(peers[data.id].displayName)), 'info'); $.notify(sprintf(locale.PASSWORD_PROTECT_ON_BY_s, stringEscape(peers[data.id].displayName)), 'info');
}); });
webrtc.on('password_protect_off', function(data){ webrtc.on('password_protect_off', function(data){
if (data.roomType == 'screen'){
return;
}
$.notify(sprintf(locale.PASSWORD_PROTECT_OFF_BY_s, stringEscape(peers[data.id].displayName)), 'info'); $.notify(sprintf(locale.PASSWORD_PROTECT_OFF_BY_s, stringEscape(peers[data.id].displayName)), 'info');
}); });
webrtc.on('owner_password_changed', function(data){ webrtc.on('owner_password_changed', function(data){
if (data.roomType == 'screen'){
return;
}
if (peers.local.role == 'owner'){ if (peers.local.role == 'owner'){
$.notify(sprintf(locale.OWNER_PASSWORD_CHANGED_BY_s, stringEscape(peers[data.id].displayName)), 'warn'); $.notify(sprintf(locale.OWNER_PASSWORD_CHANGED_BY_s, stringEscape(peers[data.id].displayName)), 'warn');
} }
@ -816,6 +835,9 @@ function initVroom(room) {
} }
}); });
webrtc.on('owner_password_removed', function(data){ webrtc.on('owner_password_removed', function(data){
if (data.roomType == 'screen'){
return;
}
if (peers.local.role == 'owner'){ if (peers.local.role == 'owner'){
$.notify(sprintf(locale.OWNER_PASSWORD_REMOVED_BY_s, stringEscape(peers[data.id].displayName)), 'warn'); $.notify(sprintf(locale.OWNER_PASSWORD_REMOVED_BY_s, stringEscape(peers[data.id].displayName)), 'warn');
} }
@ -882,15 +904,19 @@ function initVroom(room) {
webrtc.on('videoRemoved', function(video,peer){ webrtc.on('videoRemoved', function(video,peer){
playSound('leave.mp3'); playSound('leave.mp3');
var id = (peer) ? peer.id : 'local'; var id = (peer) ? peer.id : 'local';
id = (video.id.match(/_screen_/)) ? id + '_screen' : id; // Is the screen sharing of a peer being removed ?
if (video.id.match(/_screen_/)){
id = id + '_screen';
}
// Or the peer itself
else if (peer && peers[peer.id]){
delete peers[peer.id];
}
$("#peer_" + id).remove(); $("#peer_" + id).remove();
if (mainVid === id){ if (mainVid === id){
$('#mainVideo').html(''); $('#mainVideo').html('');
mainVid = false; mainVid = false;
} }
if (peer && peers[peer.id]){
delete peers[peer.id];
}
}); });
// Error sending something through dataChannel // Error sending something through dataChannel

Loading…
Cancel
Save