Skip to content

Commit

Permalink
Merge pull request #61 from whereby/nandor/pan-238-fix-knock-state-error
Browse files Browse the repository at this point in the history
Fix knock state error
  • Loading branch information
nandito authored Sep 1, 2023
2 parents 047a1f1 + c225e45 commit 98d8cca
Show file tree
Hide file tree
Showing 2 changed files with 10 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": "@whereby.com/browser-sdk",
"version": "2.0.0-alpha13",
"version": "2.0.0-alpha14",
"description": "Modules for integration Whereby video in web apps",
"author": "Whereby AS",
"license": "MIT",
Expand Down
10 changes: 9 additions & 1 deletion src/lib/RoomConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default class RoomConnection extends TypedEventTarget {
private rtcManagerDispatcher?: RtcManagerDispatcher;
private rtcManager?: RtcManager;
private roomConnectionStatus: RoomConnectionStatus;
private selfId: string | null;
private logger: Logger;
private _ownsLocalMedia = false;
private displayName?: string;
Expand All @@ -190,6 +191,7 @@ export default class RoomConnection extends TypedEventTarget {
super();
this.organizationId = "";
this.roomConnectionStatus = "";
this.selfId = null;
this.roomUrl = new URL(roomUrl); // Throw if invalid Whereby room url
const searchParams = new URLSearchParams(this.roomUrl.search);
this._roomKey = roomKey || searchParams.get("roomKey");
Expand Down Expand Up @@ -348,7 +350,12 @@ export default class RoomConnection extends TypedEventTarget {
}

private _handleKnockHandled(payload: KnockAcceptedEvent | KnockRejectedEvent) {
const { resolution } = payload;
const { clientId, resolution } = payload;

// If the knocker is not the local participant, ignore the event
if (clientId !== this.selfId) {
return;
}

if (resolution === "accepted") {
this.roomConnectionStatus = "accepted";
Expand Down Expand Up @@ -379,6 +386,7 @@ export default class RoomConnection extends TypedEventTarget {

private _handleRoomJoined(event: SignalRoomJoinedEvent) {
const { error, isLocked, room, selfId } = event;
this.selfId = selfId;
if (error === "room_locked" && isLocked) {
this.roomConnectionStatus = "room_locked";
this.dispatchEvent(
Expand Down

0 comments on commit 98d8cca

Please sign in to comment.