@@ -41,25 +41,33 @@ export class Launcher extends Observable implements DefaultLauncher {
41
41
super ( ) ;
42
42
this . logger = new Logger ( '@superviz/sdk/launcher' ) ;
43
43
44
- const { localParticipant, group, isDomainWhitelisted } = this . useStore ( StoreType . GLOBAL ) ;
45
-
46
- localParticipant . publish ( { ...participant } ) ;
44
+ const {
45
+ localParticipant : globalParticipant ,
46
+ group,
47
+ isDomainWhitelisted,
48
+ } = this . useStore ( StoreType . GLOBAL ) ;
49
+ const { localParticipant, participants } = this . useStore ( StoreType . CORE ) ;
50
+
51
+ globalParticipant . publish ( { ...participant } ) ;
47
52
isDomainWhitelisted . subscribe ( this . onAuthentication ) ;
48
- localParticipant . subscribe ( this . onLocalParticipantUpdateOnStore ) ;
53
+ globalParticipant . subscribe ( this . onLocalParticipantUpdateOnStore ) ;
54
+
55
+ localParticipant . subscribe ( this . onLocalParticipantUpdateOnCore ) ;
56
+ participants . subscribe ( this . onParticipantsListUpdateOnCore ) ;
49
57
50
58
group . publish ( participantGroup ) ;
51
- this . ioc = new IOC ( localParticipant . value ) ;
59
+ this . ioc = new IOC ( globalParticipant . value ) ;
52
60
this . room = this . ioc . createRoom ( 'launcher' , 'unlimited' ) ;
53
61
54
62
// Assign a slot to the participant
55
63
this . slotService = new SlotService ( this . room , this . useStore ) ;
56
- localParticipant . publish ( {
57
- ...localParticipant . value ,
64
+ globalParticipant . publish ( {
65
+ ...globalParticipant . value ,
58
66
slot : this . slotService . slot ,
59
67
activeComponents : [ ] ,
60
68
} ) ;
61
69
62
- this . participant = localParticipant . value ;
70
+ this . participant = globalParticipant . value ;
63
71
64
72
// internal events without realtime
65
73
this . eventBus = new EventBus ( ) ;
@@ -272,6 +280,16 @@ export class Launcher extends Observable implements DefaultLauncher {
272
280
this . activeComponents = participant . activeComponents || [ ] ;
273
281
} ;
274
282
283
+ private onLocalParticipantUpdateOnCore = ( participant : Participant ) : void => {
284
+ if ( ! this . room ) return ;
285
+ this . room . presence . update ( participant ) ;
286
+ } ;
287
+
288
+ private onParticipantsListUpdateOnCore = ( list : Record < string , Participant > ) : void => {
289
+ const { participants } = this . useStore ( StoreType . GLOBAL ) ;
290
+ participants . publish ( list ) ;
291
+ } ;
292
+
275
293
private onSameAccount = ( ) : void => {
276
294
this . publish ( ParticipantEvent . SAME_ACCOUNT_ERROR ) ;
277
295
this . destroy ( ) ;
0 commit comments