Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "refactor(service-providers): add agoraAppId config in join room" #2153

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/flat-server-api/src/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export interface JoinRoomResult {
rtmToken: string;
showGuide: boolean;
region: Region;
agoraAppId?: string;
billing?: {
/** minutes */
limit: number;
Expand Down
1 change: 0 additions & 1 deletion packages/flat-services/src/services/text-chat/text-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface IServiceTextChatJoinRoomConfig {
ownerUUID: string;
uid: string;
token?: string | null;
agoraAppId?: string | null;
}

export abstract class IServiceTextChat implements IService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface IServiceVideoChatJoinRoomConfig {
shareScreenUID: IServiceVideoChatUID;
shareScreenToken: string;
mirror?: boolean;
agoraAppId?: string | null;
}

export abstract class IServiceVideoChat implements IService {
Expand Down
2 changes: 0 additions & 2 deletions packages/flat-stores/src/classroom-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions packages/flat-stores/src/global-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -220,7 +219,6 @@ export class GlobalStore {
| "rtcUID"
| "rtcShareScreen"
| "region"
| "agoraAppId"
>
>,
): void => {
Expand All @@ -232,7 +230,6 @@ export class GlobalStore {
"rtcUID",
"rtcShareScreen",
"region",
"agoraAppId",
] as const;
for (const key of keys) {
const value = config[key];
Expand Down
2 changes: 0 additions & 2 deletions packages/flat-stores/src/room-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -145,7 +144,6 @@ export class RoomStore {
ownerUUID: data.ownerUUID,
roomType: data.roomType,
billing: data.billing,
agoraAppId: data.agoraAppId,
});
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -50,7 +52,6 @@ export class AgoraRTCWeb extends IServiceVideoChat {
private _pLeavingRoom?: Promise<unknown>;
private _testingAudio?: HTMLAudioElement;

public APP_ID: string;
public client?: IAgoraRTCClient;
public mode?: IServiceVideoChatMode;

Expand Down Expand Up @@ -357,7 +358,6 @@ export class AgoraRTCWeb extends IServiceVideoChat {
shareScreenUID,
shareScreenToken,
mirror,
agoraAppId,
}: IServiceVideoChatJoinRoomConfig): Promise<void> {
this._roomSideEffect.flushAll();

Expand Down Expand Up @@ -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,
Expand Down
12 changes: 2 additions & 10 deletions service-providers/agora-rtm/src/rtm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export class AgoraRTM extends IServiceTextChat {
private _pJoiningRoom?: Promise<unknown>;
private _pLeavingRoom?: Promise<unknown>;

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");
Expand Down Expand Up @@ -185,21 +185,13 @@ export class AgoraRTM extends IServiceTextChat {
token,
roomUUID,
ownerUUID,
agoraAppId,
}: IServiceTextChatJoinRoomConfig): Promise<void> {
this.token = token || (await generateRTMToken());

if (!this.token) {
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<void> => {
this.token = await generateRTMToken();
Expand Down
7 changes: 1 addition & 6 deletions service-providers/agora-rtm2/src/rtm2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -162,18 +162,13 @@ export class AgoraRTM2 extends IServiceTextChat {
token,
roomUUID,
ownerUUID,
agoraAppId,
}: IServiceTextChatJoinRoomConfig): Promise<void> {
this.token = token || (await generateRTMToken());

if (!this.token) {
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,
Expand Down
Loading