Skip to content

Commit

Permalink
feat: make HMSPeerType an enum
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 committed Mar 27, 2024
1 parent 2660667 commit f9eb0e8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
5 changes: 4 additions & 1 deletion packages/hms-video-store/src/interfaces/peer/hms-peer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { HMSAudioTrack, HMSTrack, HMSVideoTrack } from '../../media/tracks';
import { HMSRole } from '../role';

export type HMSPeerType = 'sip' | 'regular';
export enum HMSPeerType {
SIP = 'sip',
REGULAR = 'regular',
}

export interface HMSPeer {
peerId: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/hms-video-store/src/interfaces/peer/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type { HMSPeer, HMSPeerType } from './hms-peer';
export type { HMSPeer } from './hms-peer';
export type { HMSLocalPeer } from './hms-local-peer';
export type { HMSRemotePeer } from './hms-remote-peer';
export type { HMSConnectionQuality } from './connection-quality';
export { HMSPeerType } from './hms-peer';
15 changes: 8 additions & 7 deletions packages/hms-video-store/src/notification-manager/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { MessageNotification, PeerListNotification, PeerNotification, SpeakerList } from './HMSNotifications';
import { HMSPeerType } from '../interfaces';

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', type: 'regular' },
info: { data: 'data', name: 'Sarvesh0', user_id: 'customer_user_id', type: HMSPeerType.REGULAR },
role: 'host',
tracks: {},
groups: [],
Expand All @@ -17,7 +18,7 @@ export const fakePeerList: PeerListNotification = {
name: 'Sarvesh1',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
type: HMSPeerType.REGULAR,
},
role: 'host',
peer_id: FAKE_PEER_ID,
Expand All @@ -33,7 +34,7 @@ export const fakePeerList: PeerListNotification = {
track_id_2: {
mute: false,
type: 'video',
source: 'regular',
source: HMSPeerType.REGULAR,
description: '',
track_id: 'track_id_2',
stream_id: 'stream_id_1',
Expand All @@ -46,7 +47,7 @@ export const fakePeerList: PeerListNotification = {
name: 'Sarvesh3',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
type: HMSPeerType.REGULAR,
},
peer_id: 'peer_id_3',
role: 'viewer',
Expand Down Expand Up @@ -87,7 +88,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
name: 'Sarvesh1',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
type: HMSPeerType.REGULAR,
},
role: 'host',
peer_id: FAKE_PEER_ID,
Expand All @@ -103,7 +104,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
track_id_2: {
mute: false,
type: 'video',
source: 'regular',
source: HMSPeerType.REGULAR,
description: '',
track_id: 'track_id_2',
stream_id: 'stream_id_1',
Expand All @@ -116,7 +117,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
name: 'Sarvesh2',
data: 'data',
user_id: 'customer_user_id',
type: 'regular',
type: HMSPeerType.REGULAR,
},
peer_id: 'peer_id_2',
role: 'viewer',
Expand Down
3 changes: 2 additions & 1 deletion packages/hms-video-store/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
HMSDeviceChangeEvent,
HMSFrameworkInfo,
HMSMessageInput,
HMSPeerType,
HMSPlaylistSettings,
HMSPlaylistType,
HMSPreviewConfig,
Expand Down Expand Up @@ -1300,7 +1301,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',
type: HMSPeerType.REGULAR,
});

this.store.addPeer(localPeer);
Expand Down
18 changes: 9 additions & 9 deletions packages/hms-video-store/src/test/fakeStore/fakeHMSStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
HMSTrackSource,
HMSTrackType,
} from '../../';
import { HMSSimulcastLayer } from '../../internal';
import { HMSPeerType, HMSSimulcastLayer } from '../../internal';
import { HMSAudioTrack, HMSPlaylist, HMSPlaylistType, HMSRole, HMSScreenVideoTrack, HMSVideoTrack } from '../../schema';

function makeTrack(
Expand Down Expand Up @@ -98,7 +98,7 @@ export const makeFakeStore = (): HMSStore => {
metadata: '{}',
groups: [],
isHandRaised: false,
type: 'regular',
type: HMSPeerType.REGULAR,
},
'2': {
id: '2',
Expand All @@ -111,7 +111,7 @@ export const makeFakeStore = (): HMSStore => {
metadata: '{"hello":"world"}',
groups: [],
isHandRaised: false,
type: 'regular',
type: HMSPeerType.REGULAR,
},
'3': {
id: '3',
Expand All @@ -123,16 +123,16 @@ export const makeFakeStore = (): HMSStore => {
auxiliaryTracks: [],
groups: [],
isHandRaised: false,
type: 'regular',
type: HMSPeerType.REGULAR,
},
},
tracks: {
'101': makeTrack('101', 'video', 'regular', '1'),
'102': makeTrack('102', 'audio', 'regular', '1'),
'103': makeTrack('103', 'video', 'regular', '2'),
'104': makeTrack('104', 'audio', 'regular', '2'),
'101': makeTrack('101', 'video', HMSPeerType.REGULAR, '1'),
'102': makeTrack('102', 'audio', HMSPeerType.REGULAR, '1'),
'103': makeTrack('103', 'video', HMSPeerType.REGULAR, '2'),
'104': makeTrack('104', 'audio', HMSPeerType.REGULAR, '2'),
'105': makeTrack('105', 'video', 'screen', '2'),
'106': makeTrack('106', 'audio', 'regular', '2'),
'106': makeTrack('106', 'audio', HMSPeerType.REGULAR, '2'),
'107': makeTrack('107', 'audio', 'screen', '2'),
},
playlist: {
Expand Down
3 changes: 2 additions & 1 deletion packages/hms-video-store/src/test/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HMSPeerType } from '../interfaces';
import { HMSAudioTrack, HMSPeer, HMSTrackType, HMSVideoTrack } from '../';

let counter = 100;
Expand All @@ -20,6 +21,6 @@ export const makeFakePeer = (): HMSPeer => {
videoTrack: '',
groups: [],
isHandRaised: false,
type: 'regular',
type: HMSPeerType.REGULAR,
};
};

0 comments on commit f9eb0e8

Please sign in to comment.