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

fix: error handling for peer list iterator #2059

Merged
merged 2 commits into from
Oct 19, 2023
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
4 changes: 2 additions & 2 deletions apps/100ms-custom-app/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions apps/100ms-web/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hls-player/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hls-stats/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hms-noise-suppression/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hms-video-store/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hms-video-web/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/hms-video-web/src/sdk/HMSPeerListIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export class HMSPeerListIterator {
private defaultPaginationLimit = 10;
constructor(private transport: ITransport, private store: IStore, private options?: HMSPeerListIteratorOptions) {}

private validateConnection() {
if (!this.transport || !this.store) {
throw Error(`Use usePaginatedParticipants or hmsActions.getPeerListIterator after preview or join has happened`);
}
}

hasNext(): boolean {
return !this.isEnd;
}
Expand All @@ -22,6 +28,7 @@ export class HMSPeerListIterator {
}

async findPeers() {
this.validateConnection();
const response = await this.transport.findPeers({
...(this.options || {}),
limit: this.options?.limit || this.defaultPaginationLimit,
Expand All @@ -31,6 +38,7 @@ export class HMSPeerListIterator {
}

async next() {
this.validateConnection();
let response: PeersIterationResponse;
if (!this.iterator && !this.isEnd) {
return await this.findPeers();
Expand Down
6 changes: 0 additions & 6 deletions packages/hms-video-web/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,6 @@ export class HMSSdk implements HMSInterface {
}

getPeerListIterator(options?: HMSPeerListIteratorOptions) {
if (!this.transport || !this.store) {
throw ErrorFactory.GenericErrors.NotConnected(
HMSAction.VALIDATION,
`Ensure preview or join is called and room state is Preview or Connected before calling this`,
);
}
return new HMSPeerListIterator(this.transport, this.store, options);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/hms-virtual-background/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react-icons/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react-sdk/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/roomkit-react/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading