mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: Refactored Participant model
parent
197b46f212
commit
fb057a5823
|
@ -300,9 +300,9 @@ export class SessionComponent implements OnInit, OnDestroy {
|
|||
private subscribeToConnectionCreatedAndDestroyed() {
|
||||
this.session.on('connectionCreated', async (event: ConnectionEvent) => {
|
||||
const connectionId = event.connection?.connectionId;
|
||||
const newNickname: string = this.participantService.getNicknameFromConnectionData(event.connection.data);
|
||||
const connectionNickname: string = this.participantService.getNicknameFromConnectionData(event.connection.data);
|
||||
const isRemoteConnection: boolean = !this.openviduService.isMyOwnConnection(connectionId);
|
||||
const isCameraConnection: boolean = !newNickname?.includes(`_${VideoType.SCREEN}`);
|
||||
const isCameraConnection: boolean = !connectionNickname?.includes(`_${VideoType.SCREEN}`);
|
||||
const nickname = this.participantService.getMyNickname();
|
||||
const data = event.connection?.data;
|
||||
|
||||
|
@ -310,9 +310,9 @@ export class SessionComponent implements OnInit, OnDestroy {
|
|||
// Adding participant when connection is created and it's not screen
|
||||
this.participantService.addRemoteConnection(connectionId, data, null);
|
||||
|
||||
//Sending nicnkanme signal to new participants
|
||||
if (this.openviduService.needSendNicknameSignal(nickname)) {
|
||||
const data = { clientData: this.participantService.getMyNickname() };
|
||||
//Sending nicnkanme signal to new connection
|
||||
if (this.openviduService.myNicknameHasBeenChanged()) {
|
||||
const data = { clientData: nickname };
|
||||
await this.openviduService.sendSignal(Signal.NICKNAME_CHANGED, [event.connection], data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export interface StreamModel {
|
|||
/**
|
||||
* The streamManager object from openvidu-browser library.{@link https://docs.openvidu.io/en/stable/api/openvidu-browser/classes/StreamManager.html}
|
||||
*/
|
||||
streamManager: StreamManager;
|
||||
streamManager: StreamManager | undefined;
|
||||
/**
|
||||
* Whether the stream is enlarged or not
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ export interface StreamModel {
|
|||
/**
|
||||
* Unique identifier of the stream
|
||||
*/
|
||||
connectionId: string;
|
||||
connectionId: string | undefined;
|
||||
/**
|
||||
* The participant object
|
||||
*/
|
||||
|
@ -68,7 +68,7 @@ export abstract class ParticipantAbstractModel {
|
|||
isMutedForcibly: boolean;
|
||||
|
||||
constructor(props: ParticipantProperties, model?: StreamModel) {
|
||||
this.id = props.id ? props.id : Math.random().toString(32).replace('.','_');
|
||||
this.id = props.id || Math.random().toString(32).replace('.','_');
|
||||
this.local = props.local;
|
||||
this.nickname = props.nickname;
|
||||
this.colorProfile = !!props.colorProfile ? props.colorProfile : `hsl(${Math.random() * 360}, 100%, 80%)`;
|
||||
|
@ -76,9 +76,9 @@ export abstract class ParticipantAbstractModel {
|
|||
let streamModel: StreamModel = {
|
||||
connected: model ? model.connected : true,
|
||||
type: model ? model.type : VideoType.CAMERA,
|
||||
streamManager: model ? model.streamManager : null,
|
||||
streamManager: model?.streamManager,
|
||||
videoEnlarged: model ? model.videoEnlarged : false,
|
||||
connectionId: model ? model.connectionId : null,
|
||||
connectionId: model?.connectionId,
|
||||
participant: this
|
||||
};
|
||||
this.streams.set(streamModel.type, streamModel);
|
||||
|
@ -113,7 +113,7 @@ export abstract class ParticipantAbstractModel {
|
|||
private isCameraAudioActive(): boolean {
|
||||
const cameraConnection = this.getCameraConnection();
|
||||
if (cameraConnection?.connected) {
|
||||
return cameraConnection.streamManager?.stream?.audioActive;
|
||||
return cameraConnection.streamManager?.stream?.audioActive || false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ export abstract class ParticipantAbstractModel {
|
|||
isScreenAudioActive(): boolean {
|
||||
const screenConnection = this.getScreenConnection();
|
||||
if (screenConnection?.connected) {
|
||||
return screenConnection?.streamManager?.stream?.audioActive;
|
||||
return screenConnection?.streamManager?.stream?.audioActive || false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -557,7 +557,7 @@ export class OpenViduService {
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
needSendNicknameSignal(): boolean {
|
||||
myNicknameHasBeenChanged(): boolean {
|
||||
const participantService = this.injector.get(ParticipantService);
|
||||
let oldNickname: string = "";
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue