File tree Expand file tree Collapse file tree 3 files changed +19
-15
lines changed
Expand file tree Collapse file tree 3 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import {
1010 Session ,
1111 SESSION_CLOSE_CODE ,
1212 type SessionId ,
13- type SessionInfo
1413} from "#src/models/session.ts" ;
1514import { getWorker , type RtcWorker } from "#src/services/rtc.ts" ;
1615
@@ -203,14 +202,6 @@ export class Channel extends EventEmitter {
203202 } ;
204203 }
205204
206- get sessionsInfo ( ) : Record < SessionId , SessionInfo > {
207- const sessionsInfo : Record < SessionId , SessionInfo > = { } ;
208- for ( const session of this . sessions . values ( ) ) {
209- sessionsInfo [ session . id ] = session . info ;
210- }
211- return sessionsInfo ;
212- }
213-
214205 get webRtcServer ( ) : WebRtcServer | undefined {
215206 return this . _worker ?. appData . webRtcServer ;
216207 }
Original file line number Diff line number Diff line change @@ -573,11 +573,19 @@ export class Session extends EventEmitter {
573573 this . info [ key as keyof SessionInfo ] = Boolean ( value ) ;
574574 }
575575 }
576- if ( needRefresh ) {
576+ const sessions = this . _channel . sessions ;
577+ if ( needRefresh && sessions . size > 1 ) {
578+ const payload : Record < SessionId , SessionInfo > = { } ;
579+ for ( const session of this . _channel . sessions . values ( ) ) {
580+ if ( session . id === this . id ) {
581+ continue ;
582+ }
583+ payload [ session . id ] = session . info ;
584+ }
577585 this . bus ! . send (
578586 {
579587 name : SERVER_MESSAGE . INFO_CHANGE ,
580- payload : this . _channel . sessionsInfo
588+ payload,
581589 } ,
582590 { batch : true }
583591 ) ;
Original file line number Diff line number Diff line change @@ -117,12 +117,17 @@ describe("Full network", () => {
117117 isTalking : false ,
118118 isSelfMuted : true
119119 } ;
120- user3 . sfuClient . updateInfo ( user3Info , { needRefresh : true } ) ;
121- const [ event ] = await once ( user3 . sfuClient , "update" ) ;
120+ user3 . sfuClient . updateInfo ( user3Info ) ;
121+ const [ event ] = await once ( user2 . sfuClient , "update" ) ;
122122 expect ( event . detail . payload ) . toEqual ( {
123+ [ user3 . session . id ] : user3Info ,
124+ } ) ;
125+ // with needRefresh, the client should receive the info of all sessions except that of their own
126+ user2 . sfuClient . updateInfo ( { isTalking : true } , { needRefresh : true } ) ;
127+ const [ event2 ] = await once ( user2 . sfuClient , "update" ) ;
128+ expect ( event2 . detail . payload ) . toEqual ( {
123129 [ user1 . session . id ] : { } ,
124- [ user2 . session . id ] : { } ,
125- [ user3 . session . id ] : user3Info
130+ [ user3 . session . id ] : user3Info ,
126131 } ) ;
127132 } ) ;
128133 test ( "Connecting multiple times with the same session id closes the previous ones" , async ( ) => {
You can’t perform that action at this time.
0 commit comments