Skip to content

Commit

Permalink
chore: optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe committed Jul 12, 2024
1 parent e7f6ff2 commit 24eaae6
Show file tree
Hide file tree
Showing 5 changed files with 957 additions and 946 deletions.
20 changes: 13 additions & 7 deletions packages/rtc/src/engine/IrisClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { IrisRtcEngine } from './IrisRtcEngine';

export class IrisClient {
id: string;
//agoraRTCClient only exist after joinChannel
agoraRTCClient?: IAgoraRTCClient;
_engine: IrisRtcEngine;
irisClientState: IrisClientState;
Expand All @@ -37,15 +38,16 @@ export class IrisClient {
this.irisClientState = new IrisClientState(this._engine.globalState);
if (connection) {
this.connection = connection;
} else {
this.connection = {
channelId: '',
localUid: 0,
};
}
this.id = `irisClient_${Math.floor(Math.random() * new Date().getTime())}`;
this._engine.irisClientManager.irisClientList.push(this);
}

setConnection(connection: NATIVE_RTC.RtcConnection) {
this.connection = connection;
}

setClientConfig(): ClientConfig {
let irisClientState = this.irisClientState;
let config: ClientConfig = {
Expand Down Expand Up @@ -256,9 +258,6 @@ export class IrisClient {
}
}

this.audioTrackPackages = [];
this.videoTrackPackage = undefined;
this.agoraRTCClient = undefined;
for (
let i = 0;
i < this._engine.irisClientManager.remoteUserPackages.length;
Expand All @@ -283,5 +282,12 @@ export class IrisClient {
(item) => item.id != this.id
);
}
this.audioTrackPackages = [];
this.connection = {
channelId: '',
localUid: 0,
};
this.videoTrackPackage = undefined;
this.agoraRTCClient = undefined;
}
}
2 changes: 1 addition & 1 deletion packages/rtc/src/helper/ImplHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export class ImplHelper {
userAccount: uid as string,
});
}
irisClient.setConnection(con);
irisClient.connection = con;
this._engine.rtcEngineEventHandler.onJoinChannelSuccess_263e4cd(con, 0);
await this._engine.irisClientManager.irisClientObserver.notifyLocal(
NotifyType.PUBLISH_TRACK,
Expand Down
3 changes: 2 additions & 1 deletion packages/rtc/src/impl/IAgoraRtcEngineExImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class IRtcEngineExImpl implements NATIVE_RTC.IRtcEngineEx {
options: NATIVE_RTC.ChannelMediaOptions
): CallApiReturnType {
let processJoinChannel = async (): Promise<CallIrisApiResult> => {
let irisClient = new IrisClient(this._engine, connection);
let irisClient = new IrisClient(this._engine);
irisClient.connection = connection;
irisClient.createClient(options);
irisClient.irisClientState.token = token;
let agoraRTCClient = irisClient.agoraRTCClient;
Expand Down
Loading

0 comments on commit 24eaae6

Please sign in to comment.