mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: RPC listeners updated to support forced operations
parent
d011c5b88b
commit
cb59dbcc4d
|
@ -76,7 +76,7 @@ export class Publisher extends StreamManager {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.openvidu = openvidu;
|
this.openvidu = openvidu;
|
||||||
|
|
||||||
this.stream.ee.on('local-stream-destroyed-by-disconnect', (reason: string) => {
|
this.stream.ee.on('local-stream-destroyed', (reason: string) => {
|
||||||
const streamEvent = new StreamEvent(true, this, 'streamDestroyed', this.stream, reason);
|
const streamEvent = new StreamEvent(true, this, 'streamDestroyed', this.stream, reason);
|
||||||
this.emitEvent('streamDestroyed', [streamEvent]);
|
this.emitEvent('streamDestroyed', [streamEvent]);
|
||||||
streamEvent.callDefaultBehavior();
|
streamEvent.callDefaultBehavior();
|
||||||
|
|
|
@ -630,6 +630,10 @@ export class Session implements EventDispatcher {
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
onParticipantUnpublished(msg): void {
|
onParticipantUnpublished(msg): void {
|
||||||
|
if (msg.connectionId === this.connection.connectionId) {
|
||||||
|
// Your stream has been forcedly unpublished from the session
|
||||||
|
this.stopPublisherStream(msg.reason);
|
||||||
|
} else {
|
||||||
this.getRemoteConnection(msg.connectionId, "Remote connection '" + msg.connectionId + "' unknown when 'onParticipantUnpublished'. " +
|
this.getRemoteConnection(msg.connectionId, "Remote connection '" + msg.connectionId + "' unknown when 'onParticipantUnpublished'. " +
|
||||||
'Existing remote connections: ' + JSON.stringify(Object.keys(this.remoteConnections)))
|
'Existing remote connections: ' + JSON.stringify(Object.keys(this.remoteConnections)))
|
||||||
|
|
||||||
|
@ -648,6 +652,7 @@ export class Session implements EventDispatcher {
|
||||||
console.error(openViduError);
|
console.error(openViduError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
|
@ -860,14 +865,7 @@ export class Session implements EventDispatcher {
|
||||||
this.openvidu.closeWs();
|
this.openvidu.closeWs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!this.connection.stream) {
|
this.stopPublisherStream(reason);
|
||||||
// Dispose Publisher's local stream
|
|
||||||
this.connection.stream.disposeWebRtcPeer();
|
|
||||||
if (this.connection.stream.isLocalStreamPublished) {
|
|
||||||
// Make Publisher object dispatch 'streamDestroyed' event if the Stream was published
|
|
||||||
this.connection.stream.ee.emitEvent('local-stream-destroyed-by-disconnect', [reason]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.connection.disposed) {
|
if (!this.connection.disposed) {
|
||||||
// Make Session object dispatch 'sessionDisconnected' event (if it is not already disposed)
|
// Make Session object dispatch 'sessionDisconnected' event (if it is not already disposed)
|
||||||
|
@ -951,6 +949,17 @@ export class Session implements EventDispatcher {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private stopPublisherStream(reason: string) {
|
||||||
|
if (!!this.connection.stream) {
|
||||||
|
// Dispose Publisher's local stream
|
||||||
|
this.connection.stream.disposeWebRtcPeer();
|
||||||
|
if (this.connection.stream.isLocalStreamPublished) {
|
||||||
|
// Make Publisher object dispatch 'streamDestroyed' event if the Stream was published
|
||||||
|
this.connection.stream.ee.emitEvent('local-stream-destroyed', [reason]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private stringClientMetadata(metadata: any): string {
|
private stringClientMetadata(metadata: any): string {
|
||||||
if (typeof metadata !== 'string') {
|
if (typeof metadata !== 'string') {
|
||||||
return JSON.stringify(metadata);
|
return JSON.stringify(metadata);
|
||||||
|
|
Loading…
Reference in New Issue