Skip to content

Commit

Permalink
feat: add some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe committed Oct 22, 2023
1 parent 8b2808a commit 4c11966
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agoraio-extensions/agora-rtc-sdk-ng-fake",
"version": "1.0.4",
"version": "1.0.5",
"private": true,
"description": "Fake Agora Web RTC for testing",
"repository": {
Expand Down
37 changes: 36 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { randNumber, randUuid } from "@ngneat/falso";
import type {
ClientRole,
IAgoraRTCClient,
IAgoraRTCRemoteUser,
IRemoteAudioTrack,
Expand All @@ -13,8 +14,13 @@ import { FakeAgoraEventEmitter } from "./eventemitter";
import { FakeRemoteAudioTrack, FakeRemoteVideoTrack } from "./tracks";
import { hideProperties } from "./utils";

export const FAKE_CHANNEL_NAME = "AGORA-RTC-SDK-NG-FAKE-CHANNEL";

export class FakeRTCClient extends FakeAgoraEventEmitter {
remoteUsers: IAgoraRTCRemoteUser[] = [];
uid?: UID;
channelName?: string;
role?: ClientRole;

public static create(
executor?: Partial<IAgoraRTCClient> | ((client: FakeRTCClient) => Partial<IAgoraRTCClient>),
Expand Down Expand Up @@ -129,10 +135,39 @@ export class FakeRTCClient extends FakeAgoraEventEmitter {
}

public join(): Promise<UID> {
return Promise.resolve(randUuid());
this.uid = randUuid();
this.channelName = FAKE_CHANNEL_NAME;
return Promise.resolve(this.uid);
}

public async publish(): Promise<void> {
return Promise.resolve();
}

public async unpublish(): Promise<void> {
return Promise.resolve();
}

public leave(): Promise<void> {
this.uid = undefined;
this.channelName = undefined;
return Promise.resolve();
}

public setClientRole(): Promise<void> {
this.role = "host";
return Promise.resolve();
}

public renewToken(): Promise<void> {
return Promise.resolve();
}

public getLocalAudioStats(): void {
//
}

public getRemoteAudioStats(): void {
//
}
}
4 changes: 4 additions & 0 deletions src/tracks/local-video-track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export class FakeLocalVideoTrack extends FakeLocalTrack {
}
}

public setEncoderConfiguration(): Promise<void> {
return Promise.resolve();
}

protected _config?: VideoPlayerConfig;
protected _videoEl?: HTMLVideoElement;
}

0 comments on commit 4c11966

Please sign in to comment.