Skip to content

Commit

Permalink
feat: add type to peer
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 committed Mar 26, 2024
1 parent dc37469 commit a7d1d61
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/hms-video-store/src/interfaces/peer/hms-peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface HMSPeer {
groups?: string[];
realtime?: boolean;
isHandRaised: boolean;
type: 'sip' | 'regular';

updateRole(newRole: HMSRole): void;
updateName(newName: string): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface Info {
name: string;
data: string;
user_id: string;
type: 'sip' | 'regular';
}

export enum HMSRecordingState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const FAKE_PEER_ID = 'peer_id_1';

export const fakePeer: PeerNotification = {
peer_id: 'peer_id_0',
info: { data: 'data', name: 'Sarvesh0', user_id: 'customer_user_id' },
info: { data: 'data', name: 'Sarvesh0', user_id: 'customer_user_id', type: 'regular' },
role: 'host',
tracks: {},
groups: [],
Expand All @@ -17,6 +17,7 @@ export const fakePeerList: PeerListNotification = {
name: 'Sarvesh1',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
},
role: 'host',
peer_id: FAKE_PEER_ID,
Expand Down Expand Up @@ -45,6 +46,7 @@ export const fakePeerList: PeerListNotification = {
name: 'Sarvesh3',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
},
peer_id: 'peer_id_3',
role: 'viewer',
Expand Down Expand Up @@ -85,6 +87,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
name: 'Sarvesh1',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
},
role: 'host',
peer_id: FAKE_PEER_ID,
Expand Down Expand Up @@ -113,6 +116,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
name: 'Sarvesh2',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
},
peer_id: 'peer_id_2',
role: 'viewer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class PeerListManager {
name: peer.name,
data: peer.metadata || '',
user_id: peer.customerUserId || '',
type: peer.type,
},
tracks: {},
groups: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export const createRemotePeer = (notifPeer: PeerNotificationInfo, store: Store)
customerUserId: notifPeer.info.user_id,
metadata: notifPeer.info.data,
groups: notifPeer.groups,
type: notifPeer.info.type,
});
};
1 change: 1 addition & 0 deletions packages/hms-video-store/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,7 @@ export class HMSSdk implements HMSInterface {
role: policy,
// default value is the original role if user didn't pass asRole in config
asRole: asRolePolicy || policy,
type: 'regular',
});

this.store.addPeer(localPeer);
Expand Down
17 changes: 16 additions & 1 deletion packages/hms-video-store/src/sdk/models/peer/HMSPeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type HMSPeerInit = {
groups?: string[];
realtime?: boolean;
isHandRaised?: boolean;
type: 'sip' | 'regular';
};

export class HMSPeer implements IHMSPeer {
Expand All @@ -32,8 +33,20 @@ export class HMSPeer implements IHMSPeer {
networkQuality?: number;
groups?: string[];
realtime?: boolean;
type: 'sip' | 'regular';

constructor({ peerId, name, isLocal, customerUserId, metadata, role, joinedAt, groups, realtime }: HMSPeerInit) {
constructor({
peerId,
name,
isLocal,
customerUserId,
metadata,
role,
joinedAt,
groups,
realtime,
type,
}: HMSPeerInit) {
this.name = name;
this.peerId = peerId;
this.isLocal = isLocal;
Expand All @@ -42,6 +55,7 @@ export class HMSPeer implements IHMSPeer {
this.joinedAt = joinedAt;
this.groups = groups;
this.realtime = realtime;
this.type = type;

if (role) {
this.role = role;
Expand All @@ -68,6 +82,7 @@ export class HMSPeer implements IHMSPeer {
updateNetworkQuality(quality: number) {
this.networkQuality = quality;
}

/**
* @internal
*/
Expand Down

0 comments on commit a7d1d61

Please sign in to comment.