Skip to content

Commit

Permalink
Ignore label of data channel when processing received messages.
Browse files Browse the repository at this point in the history
This is necessary for support of Janus 1.x which will use the
(random) id of the publisher that sent the message as label.

Signed-off-by: Joachim Bauch <bauch@struktur.de>
  • Loading branch information
fancycode committed Feb 27, 2024
1 parent fca0fae commit dd2ab2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/utils/webrtc/models/CallParticipantModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ CallParticipantModel.prototype = {
return
}

if (label !== 'status' && label !== 'JanusDataChannel') {
return
}

if (data.type === 'speaking') {
this.set('speaking', true)
} else if (data.type === 'stoppedSpeaking') {
Expand Down
32 changes: 14 additions & 18 deletions src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1594,25 +1594,21 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local
})

webrtc.on('channelMessage', function(peer, label, data) {
if (label === 'status' || label === 'JanusDataChannel') {
if (data.type === 'audioOn') {
webrtc.emit('unmute', { id: peer.id, name: 'audio' })
} else if (data.type === 'audioOff') {
webrtc.emit('mute', { id: peer.id, name: 'audio' })
} else if (data.type === 'videoOn') {
webrtc.emit('unmute', { id: peer.id, name: 'video' })
} else if (data.type === 'videoOff') {
webrtc.emit('mute', { id: peer.id, name: 'video' })
} else if (data.type === 'nickChanged') {
const name = typeof (data.payload) === 'string' ? data.payload : data.payload.name
webrtc.emit('nick', { id: peer.id, name })
} else if (data.type === 'speaking' || data.type === 'stoppedSpeaking') {
// Valid known messages, handled by CallParticipantModel.js
} else {
console.debug('Unknown message type %s from %s datachannel', data.type, label, data, peer.id, peer)
}
if (data.type === 'audioOn') {
webrtc.emit('unmute', { id: peer.id, name: 'audio' })
} else if (data.type === 'audioOff') {
webrtc.emit('mute', { id: peer.id, name: 'audio' })
} else if (data.type === 'videoOn') {
webrtc.emit('unmute', { id: peer.id, name: 'video' })
} else if (data.type === 'videoOff') {
webrtc.emit('mute', { id: peer.id, name: 'video' })
} else if (data.type === 'nickChanged') {
const name = typeof (data.payload) === 'string' ? data.payload : data.payload.name
webrtc.emit('nick', { id: peer.id, name })
} else if (data.type === 'speaking' || data.type === 'stoppedSpeaking') {
// Valid known messages, handled by CallParticipantModel.js
} else {
console.debug('Unknown message from %s datachannel', label, data, peer.id, peer)
console.debug('Unknown message type %s from %s datachannel', data.type, label, data, peer.id, peer)
}
})

Expand Down

0 comments on commit dd2ab2b

Please sign in to comment.