mirror of https://github.com/OpenVidu/openvidu.git
Bug fix: race condition of "streamCreated" event (triggered by "joinRoom" callback and "onParticipantPublished)
parent
88d017dc18
commit
df074b5d15
|
@ -305,15 +305,17 @@ export class SessionInternal {
|
|||
console.debug("Remote Connection found in connections list by its id [" + pid + "]");
|
||||
}
|
||||
|
||||
|
||||
this.participants[pid] = connection;
|
||||
|
||||
this.ee.emitEvent('participant-published', [{ connection }]);
|
||||
|
||||
let streams = connection.getStreams();
|
||||
for (let key in streams) {
|
||||
let stream = streams[key];
|
||||
|
||||
if (!this.streams[stream.streamId]) {
|
||||
// Avoid race condition between stream.subscribe() in "onParticipantPublished" and in "joinRoom" rpc callback
|
||||
// This condition is false if openvidu-server sends "participantPublished" event to a subscriber participant that has
|
||||
// already subscribed to certain stream in the callback of "joinRoom" method
|
||||
|
||||
if (this.subscribeToStreams) {
|
||||
stream.subscribe();
|
||||
}
|
||||
|
@ -321,6 +323,8 @@ export class SessionInternal {
|
|||
|
||||
// Adding the remote stream to the OpenVidu object
|
||||
this.openVidu.getRemoteStreams().push(stream);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue