diff --git a/packages/hms-video-store/src/index.ts b/packages/hms-video-store/src/index.ts index 7489c77b8b..ad9e01d8cd 100644 --- a/packages/hms-video-store/src/index.ts +++ b/packages/hms-video-store/src/index.ts @@ -51,6 +51,7 @@ export type { HMSPollQuestionOption, HMSQuizLeaderboardResponse, HMSQuizLeaderboardSummary, + HMSPeerType, } from './internal'; export { EventBus } from './events/EventBus'; diff --git a/packages/hms-video-store/src/interfaces/peer/hms-peer.ts b/packages/hms-video-store/src/interfaces/peer/hms-peer.ts index 1e1b557f54..f3788b964d 100644 --- a/packages/hms-video-store/src/interfaces/peer/hms-peer.ts +++ b/packages/hms-video-store/src/interfaces/peer/hms-peer.ts @@ -1,6 +1,8 @@ import { HMSAudioTrack, HMSTrack, HMSVideoTrack } from '../../media/tracks'; import { HMSRole } from '../role'; +export type HMSPeerType = 'sip' | 'regular'; + export interface HMSPeer { peerId: string; name: string; @@ -16,6 +18,7 @@ export interface HMSPeer { groups?: string[]; realtime?: boolean; isHandRaised: boolean; + type: HMSPeerType; updateRole(newRole: HMSRole): void; updateName(newName: string): void; diff --git a/packages/hms-video-store/src/interfaces/peer/index.ts b/packages/hms-video-store/src/interfaces/peer/index.ts index 861ab7619d..1b4b1f69af 100644 --- a/packages/hms-video-store/src/interfaces/peer/index.ts +++ b/packages/hms-video-store/src/interfaces/peer/index.ts @@ -1,4 +1,4 @@ -export type { HMSPeer } from './hms-peer'; +export type { HMSPeer, HMSPeerType } from './hms-peer'; export type { HMSLocalPeer } from './hms-local-peer'; export type { HMSRemotePeer } from './hms-remote-peer'; export type { HMSConnectionQuality } from './connection-quality'; diff --git a/packages/hms-video-store/src/notification-manager/HMSNotifications.ts b/packages/hms-video-store/src/notification-manager/HMSNotifications.ts index d6487f9c78..9fbfe894d9 100644 --- a/packages/hms-video-store/src/notification-manager/HMSNotifications.ts +++ b/packages/hms-video-store/src/notification-manager/HMSNotifications.ts @@ -1,4 +1,5 @@ import { VideoTrackLayerUpdate } from '../connection/channel-messages'; +import { HMSPeerType } from '../interfaces/peer/hms-peer'; import { HMSRole } from '../interfaces/role'; import { HMSLocalTrack } from '../media/tracks'; import { HMSTrack, HMSTrackSource } from '../media/tracks/HMSTrack'; @@ -39,6 +40,7 @@ export interface Info { name: string; data: string; user_id: string; + type: HMSPeerType; } export enum HMSRecordingState { diff --git a/packages/hms-video-store/src/notification-manager/fixtures.ts b/packages/hms-video-store/src/notification-manager/fixtures.ts index c02f5f972f..0764ff3985 100644 --- a/packages/hms-video-store/src/notification-manager/fixtures.ts +++ b/packages/hms-video-store/src/notification-manager/fixtures.ts @@ -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: [], @@ -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, @@ -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', @@ -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, @@ -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', diff --git a/packages/hms-video-store/src/notification-manager/managers/PeerListManager.ts b/packages/hms-video-store/src/notification-manager/managers/PeerListManager.ts index 5d0f46f6c9..021f9ca54e 100644 --- a/packages/hms-video-store/src/notification-manager/managers/PeerListManager.ts +++ b/packages/hms-video-store/src/notification-manager/managers/PeerListManager.ts @@ -98,6 +98,7 @@ export class PeerListManager { name: peer.name, data: peer.metadata || '', user_id: peer.customerUserId || '', + type: peer.type, }, tracks: {}, groups: [], diff --git a/packages/hms-video-store/src/notification-manager/managers/utils.ts b/packages/hms-video-store/src/notification-manager/managers/utils.ts index 57e3d3aeab..e2a98004e9 100644 --- a/packages/hms-video-store/src/notification-manager/managers/utils.ts +++ b/packages/hms-video-store/src/notification-manager/managers/utils.ts @@ -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, }); }; diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index 6d63e78958..a8cd2d2091 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -51,6 +51,7 @@ export class SDKToHMS { joinedAt: sdkPeer.joinedAt, groups: sdkPeer.groups, isHandRaised: sdkPeer.isHandRaised, + type: sdkPeer.type, }; } diff --git a/packages/hms-video-store/src/schema/peer.ts b/packages/hms-video-store/src/schema/peer.ts index 51b0386519..a9d40d0dfe 100644 --- a/packages/hms-video-store/src/schema/peer.ts +++ b/packages/hms-video-store/src/schema/peer.ts @@ -5,6 +5,7 @@ import { HMSSimulcastLayerDefinition, ScreenCaptureHandle, } from '../interfaces'; +import { HMSPeerType } from '../interfaces/peer/hms-peer'; export type HMSPeerID = string; export type HMSTrackID = string; @@ -42,6 +43,7 @@ export interface HMSPeer { joinedAt?: Date; groups?: HMSGroupName[]; isHandRaised: boolean; + type: HMSPeerType; } /** diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts index 5da120f4cf..c7088c3c90 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts @@ -96,6 +96,7 @@ const publishParams = hostRole.publishParams; let localPeer = new HMSLocalPeer({ name: 'test', role: hostRole, + type: 'regular', }); testStore.addPeer(localPeer); @@ -231,6 +232,7 @@ describe('LocalTrackManager', () => { localPeer = new HMSLocalPeer({ name: 'test', role: hostRole, + type: 'regular', }); testStore.addPeer(localPeer); }); @@ -408,6 +410,7 @@ describe('LocalTrackManager', () => { localPeer = new HMSLocalPeer({ name: 'test', role: hostRole, + type: 'regular', }); testStore.addPeer(localPeer); mockGetUserMedia.mockClear(); diff --git a/packages/hms-video-store/src/sdk/index.ts b/packages/hms-video-store/src/sdk/index.ts index f276305cdf..3532316635 100644 --- a/packages/hms-video-store/src/sdk/index.ts +++ b/packages/hms-video-store/src/sdk/index.ts @@ -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); diff --git a/packages/hms-video-store/src/sdk/models/peer/HMSPeer.ts b/packages/hms-video-store/src/sdk/models/peer/HMSPeer.ts index b119db956f..54bf7547c8 100644 --- a/packages/hms-video-store/src/sdk/models/peer/HMSPeer.ts +++ b/packages/hms-video-store/src/sdk/models/peer/HMSPeer.ts @@ -1,4 +1,5 @@ import { HMSPeer as IHMSPeer } from '../../../interfaces/peer'; +import { HMSPeerType } from '../../../interfaces/peer/hms-peer'; import { HMSRole } from '../../../interfaces/role'; import { HMSAudioTrack, HMSTrack, HMSVideoTrack } from '../../../media/tracks'; import { HAND_RAISE_GROUP_NAME } from '../../../utils/constants'; @@ -16,6 +17,7 @@ export type HMSPeerInit = { groups?: string[]; realtime?: boolean; isHandRaised?: boolean; + type: HMSPeerType; }; export class HMSPeer implements IHMSPeer { @@ -32,8 +34,20 @@ export class HMSPeer implements IHMSPeer { networkQuality?: number; groups?: string[]; realtime?: boolean; + type: HMSPeerType; - 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; @@ -42,6 +56,7 @@ export class HMSPeer implements IHMSPeer { this.joinedAt = joinedAt; this.groups = groups; this.realtime = realtime; + this.type = type; if (role) { this.role = role; @@ -68,6 +83,7 @@ export class HMSPeer implements IHMSPeer { updateNetworkQuality(quality: number) { this.networkQuality = quality; } + /** * @internal */ diff --git a/packages/hms-video-store/src/sdk/models/peer/peer.test.ts b/packages/hms-video-store/src/sdk/models/peer/peer.test.ts index c459790c5a..b463bf03ff 100644 --- a/packages/hms-video-store/src/sdk/models/peer/peer.test.ts +++ b/packages/hms-video-store/src/sdk/models/peer/peer.test.ts @@ -1,5 +1,6 @@ import { HMSLocalPeer } from './HMSLocalPeer'; import { HMSRemotePeer } from './HMSRemotePeer'; +import { HMSPeerType } from '../../../internal'; import { PeerNotification } from '../../../notification-manager'; import decodeJWT from '../../../utils/jwt'; @@ -45,6 +46,7 @@ describe('HMSLocalPeer', () => { name: 'John Doe', role: getParamsForRole(role), customerUserId: userId, + type: 'regular' as HMSPeerType, }; const peer = new HMSLocalPeer(params); @@ -80,6 +82,7 @@ describe('HMSRemotPeer', () => { name: 'John Doe', data: 'data', user_id: 'customer_user_id', + type: 'regular', }, role: 'viewer', tracks: {}, @@ -91,6 +94,7 @@ describe('HMSRemotPeer', () => { role: getParamsForRole(peerInfo.role), customerUserId: peerInfo.info.user_id, metadata: peerInfo.info.data, + type: 'regular', }); it('should be constructed using params', () => { diff --git a/packages/hms-video-store/src/test/fakeStore/fakeHMSStore.ts b/packages/hms-video-store/src/test/fakeStore/fakeHMSStore.ts index a0aecfc784..16cd092863 100644 --- a/packages/hms-video-store/src/test/fakeStore/fakeHMSStore.ts +++ b/packages/hms-video-store/src/test/fakeStore/fakeHMSStore.ts @@ -98,6 +98,7 @@ export const makeFakeStore = (): HMSStore => { metadata: '{}', groups: [], isHandRaised: false, + type: 'regular', }, '2': { id: '2', @@ -110,6 +111,7 @@ export const makeFakeStore = (): HMSStore => { metadata: '{"hello":"world"}', groups: [], isHandRaised: false, + type: 'regular', }, '3': { id: '3', @@ -121,6 +123,7 @@ export const makeFakeStore = (): HMSStore => { auxiliaryTracks: [], groups: [], isHandRaised: false, + type: 'regular', }, }, tracks: { diff --git a/packages/hms-video-store/src/test/fixtures.ts b/packages/hms-video-store/src/test/fixtures.ts index dd624ecedd..af71471999 100644 --- a/packages/hms-video-store/src/test/fixtures.ts +++ b/packages/hms-video-store/src/test/fixtures.ts @@ -20,5 +20,6 @@ export const makeFakePeer = (): HMSPeer => { videoTrack: '', groups: [], isHandRaised: false, + type: 'regular', }; }; diff --git a/packages/roomkit-react/src/fixtures/peers.ts b/packages/roomkit-react/src/fixtures/peers.ts index 7a34f215ed..0fe555d50e 100644 --- a/packages/roomkit-react/src/fixtures/peers.ts +++ b/packages/roomkit-react/src/fixtures/peers.ts @@ -11,6 +11,7 @@ export const makeFakeParticipant = (name: string, role = 'Student'): HMSPeerWith isLocal: counter === 1, groups: [], isHandRaised: false, + type: 'regular', }, isAudioEnabled: false, };