Skip to content
Prev Previous commit
Next Next commit
Send and handle "nickChanged" message also through signaling
When the HPB is used, if the local participant does not send audio nor
video there is no Peer for the local participant, so it is not possible
to send data channel messages (although they can be received if the
other participant sends audio or video and thus has a Peer object). When
the HPB is not used, if both the local participant and the remote one do
not send audio nor video there is no Peer for their connection, so it is
not possible to send or received data channel messages between those
participants.

The nick was only sent through data channel messages, so in the above
cases the nick was not initially shown and neither updated if it was
changed later. Now a "nickChanged" signaling message is introduced to
ensure that the nick is transmitted even if there is no Peer for a
participant.

Even if the mobile apps do not currently handle the "nickChanged" event
they will just ignore it without breaking havoc.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and backportbot[bot] committed Nov 19, 2020
commit 4db0e4b8481af2b6871afad5f04506d30cd11989
3 changes: 2 additions & 1 deletion src/utils/webrtc/models/CallParticipantModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ CallParticipantModel.prototype = {
},

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

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 @@ -119,6 +119,10 @@ function SimpleWebRTC(opts) {
self.emit('mute', { id: message.payload.peerId })
}
}
} else if (message.type === 'nickChanged') {
// "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 (peers.length) {
peers.forEach(function(peer) {
if (message.sid && !self.connection.hasFeature('mcu')) {
Expand Down
23 changes: 22 additions & 1 deletion src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local
sendDataChannelToAll('status', 'videoOff')
})

// Send the nick changed event via data channel
// Send the nick changed event via data channel and signaling
webrtc.on('nickChanged', function(name) {
let payload
if (signaling.settings.userId === null) {
Expand All @@ -984,6 +984,27 @@ 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)
}
})

// Local screen added.
Expand Down