Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move "forceReconnect" function to be able to use it in a previous line
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and nickvergessen committed Aug 21, 2020
commit 35fe5ff602ccdaf8df11fb4015e789a79b692a54
40 changes: 20 additions & 20 deletions src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,26 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local
})
}

const forceReconnect = function(signaling, flags) {
if (ownPeer) {
webrtc.removePeers(ownPeer.id)
ownPeer.end()
ownPeer = null

localCallParticipantModel.setPeer(ownPeer)
}

usersChanged(signaling, [], previousUsersInRoom)
usersInCallMapping = {}
previousUsersInRoom = []

// Reconnects with a new session id will trigger "usersChanged"
// with the users in the room and that will re-establish the
// peerconnection streams.
// If flags are undefined the current call flags are used.
signaling.forceReconnect(true, flags)
}

webrtc.on('createdPeer', function(peer) {
console.debug('Peer created', peer)

Expand Down Expand Up @@ -734,26 +754,6 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local
stopPeerCheckMedia(peer)
})

const forceReconnect = function(signaling, flags) {
if (ownPeer) {
webrtc.removePeers(ownPeer.id)
ownPeer.end()
ownPeer = null

localCallParticipantModel.setPeer(ownPeer)
}

usersChanged(signaling, [], previousUsersInRoom)
usersInCallMapping = {}
previousUsersInRoom = []

// Reconnects with a new session id will trigger "usersChanged"
// with the users in the room and that will re-establish the
// peerconnection streams.
// If flags are undefined the current call flags are used.
signaling.forceReconnect(true, flags)
}

webrtc.webrtc.on('videoOn', function() {
if (signaling.getSendVideoIfAvailable()) {
return
Expand Down