From c9ca65877b7220a801132df52b24ba7ce818f8ef Mon Sep 17 00:00:00 2001 From: hqer927 <41457198+hqer927@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:41:12 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"refactor(service-providers):=20add=20?= =?UTF-8?q?`agoraAppId`=20config=20in=20join=20room=20(#2=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4ff804168575a37a7892d3d3cbe1a35b12d547f3. --- packages/flat-server-api/src/room.ts | 1 - .../src/services/text-chat/text-chat.ts | 1 - .../src/services/video-chat/video-chat.ts | 1 - packages/flat-stores/src/classroom-store/index.ts | 2 -- packages/flat-stores/src/global-store.ts | 3 --- packages/flat-stores/src/room-store.ts | 2 -- .../agora-rtc-electron/src/agora-rtc-electron.ts | 9 +-------- .../agora-rtc/agora-rtc-web/src/agora-rtc-web.ts | 8 ++------ service-providers/agora-rtm/src/rtm.ts | 12 ++---------- service-providers/agora-rtm2/src/rtm2.ts | 7 +------ 10 files changed, 6 insertions(+), 40 deletions(-) diff --git a/packages/flat-server-api/src/room.ts b/packages/flat-server-api/src/room.ts index 82a94646cfe..59439f4c4d6 100644 --- a/packages/flat-server-api/src/room.ts +++ b/packages/flat-server-api/src/room.ts @@ -103,7 +103,6 @@ export interface JoinRoomResult { rtmToken: string; showGuide: boolean; region: Region; - agoraAppId?: string; billing?: { /** minutes */ limit: number; diff --git a/packages/flat-services/src/services/text-chat/text-chat.ts b/packages/flat-services/src/services/text-chat/text-chat.ts index e21e745e063..e193384d436 100644 --- a/packages/flat-services/src/services/text-chat/text-chat.ts +++ b/packages/flat-services/src/services/text-chat/text-chat.ts @@ -14,7 +14,6 @@ export interface IServiceTextChatJoinRoomConfig { ownerUUID: string; uid: string; token?: string | null; - agoraAppId?: string | null; } export abstract class IServiceTextChat implements IService { diff --git a/packages/flat-services/src/services/video-chat/video-chat.ts b/packages/flat-services/src/services/video-chat/video-chat.ts index 33909a0f5ce..78ea444061b 100644 --- a/packages/flat-services/src/services/video-chat/video-chat.ts +++ b/packages/flat-services/src/services/video-chat/video-chat.ts @@ -30,7 +30,6 @@ export interface IServiceVideoChatJoinRoomConfig { shareScreenUID: IServiceVideoChatUID; shareScreenToken: string; mirror?: boolean; - agoraAppId?: string | null; } export abstract class IServiceVideoChat implements IService { diff --git a/packages/flat-stores/src/classroom-store/index.ts b/packages/flat-stores/src/classroom-store/index.ts index b21e601f3cc..7dfe418d54e 100644 --- a/packages/flat-stores/src/classroom-store/index.ts +++ b/packages/flat-stores/src/classroom-store/index.ts @@ -376,7 +376,6 @@ export class ClassroomStore { ownerUUID: this.ownerUUID, uid: this.userUUID, token: globalStore.rtmToken, - agoraAppId: globalStore.agoraAppId, }); const fastboard = await this.whiteboardStore.joinWhiteboardRoom(); @@ -1509,7 +1508,6 @@ export class ClassroomStore { shareScreenUID: String(globalStore.rtcShareScreen?.uid || -1), shareScreenToken: globalStore.rtcShareScreen?.token || "", mirror: preferencesStore.mirrorMode, - agoraAppId: globalStore.agoraAppId, }); if (preferencesStore.cameraId) { diff --git a/packages/flat-stores/src/global-store.ts b/packages/flat-stores/src/global-store.ts index 7b9dec6aef8..c4e013b7d49 100644 --- a/packages/flat-stores/src/global-store.ts +++ b/packages/flat-stores/src/global-store.ts @@ -67,7 +67,6 @@ export class GlobalStore { * Room's region, services (currently only whiteboard) must use this value to join the room. */ public region: Region | null = null; - public agoraAppId: string | null = null; public rtcToken: string | null = null; public rtcUID: number | null = null; public rtcShareScreen: { @@ -220,7 +219,6 @@ export class GlobalStore { | "rtcUID" | "rtcShareScreen" | "region" - | "agoraAppId" > >, ): void => { @@ -232,7 +230,6 @@ export class GlobalStore { "rtcUID", "rtcShareScreen", "region", - "agoraAppId", ] as const; for (const key of keys) { const value = config[key]; diff --git a/packages/flat-stores/src/room-store.ts b/packages/flat-stores/src/room-store.ts index a990450aedb..05820dab37c 100644 --- a/packages/flat-stores/src/room-store.ts +++ b/packages/flat-stores/src/room-store.ts @@ -57,7 +57,6 @@ export interface RoomItem { expireAt: number; vipLevel: 0 | 1; }; - agoraAppId?: string; } // Only keep sub-room ids. sub-room info are stored in ordinaryRooms. @@ -145,7 +144,6 @@ export class RoomStore { ownerUUID: data.ownerUUID, roomType: data.roomType, billing: data.billing, - agoraAppId: data.agoraAppId, }); return data; } diff --git a/service-providers/agora-rtc/agora-rtc-electron/src/agora-rtc-electron.ts b/service-providers/agora-rtc/agora-rtc-electron/src/agora-rtc-electron.ts index 9c54ee069a5..999ff1b37ab 100644 --- a/service-providers/agora-rtc/agora-rtc-electron/src/agora-rtc-electron.ts +++ b/service-providers/agora-rtc/agora-rtc-electron/src/agora-rtc-electron.ts @@ -32,12 +32,11 @@ export class AgoraRTCElectron extends IServiceVideoChat { public readonly isMac: boolean; public readonly shareScreen = new AgoraRTCElectronShareScreen({ rtc: this }); + public readonly APP_ID: string; public readonly rtcEngine: AgoraSdk; private readonly _roomSideEffect = new SideEffectManager(); - public APP_ID: string; - private _cameraID?: string; private _micID?: string; private _speakerID?: string; @@ -204,12 +203,6 @@ export class AgoraRTCElectron extends IServiceVideoChat { } this.leaveRoom(); } - - if (config.agoraAppId && config.agoraAppId !== this.APP_ID) { - this.rtcEngine.release(true); - this.rtcEngine.initialize((this.APP_ID = config.agoraAppId)); - } - return this._join(config); } diff --git a/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts b/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts index 930ce70cab8..4028fa60ac3 100644 --- a/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts +++ b/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts @@ -42,6 +42,8 @@ export interface AgoraRTCWebConfig { } export class AgoraRTCWeb extends IServiceVideoChat { + public readonly APP_ID: string; + public readonly shareScreen: AgoraRTCWebShareScreen; private readonly _roomSideEffect = new SideEffectManager(); @@ -50,7 +52,6 @@ export class AgoraRTCWeb extends IServiceVideoChat { private _pLeavingRoom?: Promise; private _testingAudio?: HTMLAudioElement; - public APP_ID: string; public client?: IAgoraRTCClient; public mode?: IServiceVideoChatMode; @@ -357,7 +358,6 @@ export class AgoraRTCWeb extends IServiceVideoChat { shareScreenUID, shareScreenToken, mirror, - agoraAppId, }: IServiceVideoChatJoinRoomConfig): Promise { this._roomSideEffect.flushAll(); @@ -494,10 +494,6 @@ export class AgoraRTCWeb extends IServiceVideoChat { }), ); - if (agoraAppId && agoraAppId !== this.APP_ID) { - this.APP_ID = agoraAppId; - } - await client.join( this.APP_ID, roomUUID, diff --git a/service-providers/agora-rtm/src/rtm.ts b/service-providers/agora-rtm/src/rtm.ts index 4024c39482e..78729b7e5a1 100644 --- a/service-providers/agora-rtm/src/rtm.ts +++ b/service-providers/agora-rtm/src/rtm.ts @@ -24,14 +24,14 @@ export class AgoraRTM extends IServiceTextChat { private _pJoiningRoom?: Promise; private _pLeavingRoom?: Promise; - public client: RtmClient; + public readonly client: RtmClient; public channel?: RtmChannel; private roomUUID?: string; private userUUID?: string; private token?: string; - public constructor(public APP_ID: string) { + public constructor(APP_ID: string) { super(); if (!APP_ID) { throw new Error("APP_ID is not set"); @@ -185,7 +185,6 @@ export class AgoraRTM extends IServiceTextChat { token, roomUUID, ownerUUID, - agoraAppId, }: IServiceTextChatJoinRoomConfig): Promise { this.token = token || (await generateRTMToken()); @@ -193,13 +192,6 @@ export class AgoraRTM extends IServiceTextChat { throw new Error("Missing Agora RTM token"); } - if (agoraAppId && agoraAppId !== this.APP_ID) { - this.APP_ID = agoraAppId; - this.client = RtmEngine.createInstance(this.APP_ID, { - logFilter: RtmEngine.LOG_FILTER_WARNING, - }); - } - this._roomSideEffect.add(() => { const handler = async (): Promise => { this.token = await generateRTMToken(); diff --git a/service-providers/agora-rtm2/src/rtm2.ts b/service-providers/agora-rtm2/src/rtm2.ts index 8b45ad7aa5d..e990127d2a1 100644 --- a/service-providers/agora-rtm2/src/rtm2.ts +++ b/service-providers/agora-rtm2/src/rtm2.ts @@ -28,7 +28,7 @@ export class AgoraRTM2 extends IServiceTextChat { private userUUID?: string; private token?: string; - public constructor(public APP_ID: string) { + public constructor(private readonly APP_ID: string) { super(); if (!APP_ID) { throw new Error("APP_ID is not set"); @@ -162,7 +162,6 @@ export class AgoraRTM2 extends IServiceTextChat { token, roomUUID, ownerUUID, - agoraAppId, }: IServiceTextChatJoinRoomConfig): Promise { this.token = token || (await generateRTMToken()); @@ -170,10 +169,6 @@ export class AgoraRTM2 extends IServiceTextChat { throw new Error("Missing Agora RTM token"); } - if (agoraAppId && agoraAppId !== this.APP_ID) { - this.APP_ID = agoraAppId; - } - const client = (this.client = new RTM(this.APP_ID, uid, { logLevel: "warn", logUpload: !process.env.DEV,