Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/utils/webrtc/models/CallParticipantModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ CallParticipantModel.prototype = {
},

_handleRaisedHand: function(data) {
if (!this.get('peer') || this.get('peer').id !== data.id) {
// The hand could be raised even if there is no Peer object.
if (this.get('peerId') !== data.id) {
return
}

Expand Down
2 changes: 0 additions & 2 deletions src/utils/webrtc/simplewebrtc/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ Peer.prototype.handleMessage = function(message) {
} else if (message.type === 'unshareScreen') {
this.parent.emit('unshareScreen', { id: message.from })
this.end()
} else if (message.type === 'raiseHand') {
this.parent.emit('raisedHand', { id: message.from, raised: message.payload })
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/utils/webrtc/simplewebrtc/simplewebrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ function SimpleWebRTC(opts) {
// "nickChanged" can be received from a participant without a Peer
// object if that participant is not sending audio nor video.
self.emit('nick', { id: message.from, name: message.payload.name })
} else if (message.type === 'raiseHand') {
// "raisedHand" can be received from a participant without a Peer
// object if that participant is not sending audio nor video.
self.emit('raisedHand', { id: message.from, raised: message.payload })
} else if (peers.length) {
peers.forEach(function(peer) {
if (message.sid && !self.connection.hasFeature('mcu')) {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/webrtc/simplewebrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ WebRTC.prototype.sendToAll = function(message, payload) {
this.peers.forEach(function(peer) {
peer.send(message, payload)
})

this.emit('sendToAll', message, payload)
}

// sends message to all using a datachannel
Expand Down
53 changes: 33 additions & 20 deletions src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,38 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local
}
})

webrtc.on('sendToAll', function(messageType, payload) {
const sessionIdsForParticipantsWithPeers = {}
webrtc.webrtc.peers.forEach(peer => {
sessionIdsForParticipantsWithPeers[peer.id] = peer
})

// "webrtc.sendToAll" only sends the signaling message to participants
// for which there is a Peer object. Therefore the message needs to be
// explicitly sent here too to participants without audio and video.
for (const sessionId in usersInCallMapping) {
if (sessionIdsForParticipantsWithPeers[sessionId]) {
continue
} else if (!usersInCallMapping[sessionId].inCall) {
continue
} else if (sessionId === signaling.getSessionId()) {
continue
}

// "roomType" is not really relevant without a peer, but it is
// nevertheless expected in the message. As the signaling messages
// currently sent to all participants are related to video peers
// "video" is used as the room type.
const message = {
to: sessionId,
roomType: 'video',
type: messageType,
payload: payload,
}
signaling.emit('message', message)
}
})

webrtc.on('speaking', function() {
sendDataChannelToAll('status', 'speaking')
})
Expand Down Expand Up @@ -1093,26 +1125,7 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local

sendDataChannelToAll('status', 'nickChanged', payload)

// "webrtc.sendToAll" can not be used, as it only sends the signaling
// message to participants for which there is a Peer object, so the
// message may not be sent to participants without audio and video.
for (const sessionId in usersInCallMapping) {
if (!usersInCallMapping[sessionId].inCall) {
continue
} else if (sessionId === signaling.getSessionId()) {
continue
}

const message = {
to: sessionId,
roomType: 'video',
type: 'nickChanged',
payload: {
name: name,
},
}
signaling.emit('message', message)
}
webrtc.sendToAll('nickChanged', { name: name })
})

// Local screen added.
Expand Down