@@ -276,13 +276,8 @@ export class MembershipManager
276276 if ( ! this . isActivated ( ) ) {
277277 return Promise . resolve ( ) ;
278278 }
279- const userId = this . client . getUserId ( ) ;
280- const deviceId = this . client . getDeviceId ( ) ;
281- if ( ! userId || ! deviceId ) {
282- this . logger . error ( "MembershipManager.onRTCSessionMemberUpdate called without user or device id" ) ;
283- return Promise . resolve ( ) ;
284- }
285- this . _ownMembership = memberships . find ( ( m ) => isMyMembership ( m , userId , deviceId ) ) ;
279+
280+ this . _ownMembership = memberships . find ( ( m ) => isMyMembership ( m , this . userId , this . deviceId ) ) ;
286281
287282 if ( ! this . _ownMembership ) {
288283 // If one of these actions are scheduled or are getting inserted in the next iteration, we should already
@@ -338,6 +333,7 @@ export class MembershipManager
338333 if ( userId === null ) throw Error ( "Missing userId in client" ) ;
339334 if ( deviceId === null ) throw Error ( "Missing deviceId in client" ) ;
340335 this . deviceId = deviceId ;
336+ this . userId = userId ;
341337 // this needs to become a uuid so that consecutive join/leaves result in a key rotation.
342338 // we keep it as a string for now for backwards compatibility.
343339 this . memberId = this . makeMembershipStateKey ( userId , deviceId ) ;
@@ -386,6 +382,7 @@ export class MembershipManager
386382 }
387383 // Membership Event static parameters:
388384 protected deviceId : string ;
385+ protected userId : string ;
389386 protected memberId : string ;
390387 protected rtcTransport ?: Transport ;
391388 /** @deprecated This will be removed in favor or rtcTransport becoming a list of actively used transports */
@@ -763,6 +760,10 @@ export class MembershipManager
763760 }
764761
765762 // HELPERS
763+ /**
764+ * this creates `${localUserId}_${localDeviceId}_${this.slotDescription.application}${this.slotDescription.id}`
765+ * which is not compatible with membershipID of session type member events. They have to be `${localUserId}:${localDeviceId}`
766+ */
766767 private makeMembershipStateKey ( localUserId : string , localDeviceId : string ) : string {
767768 const stateKey = `${ localUserId } _${ localDeviceId } _${ this . slotDescription . application } ${ this . slotDescription . id } ` ;
768769 if ( / ^ o r g \. m a t r i x \. m s c ( 3 7 5 7 | 3 7 7 9 ) \b / . exec ( this . room . getVersion ( ) ) ) {
@@ -793,6 +794,10 @@ export class MembershipManager
793794 "call_id" : this . slotDescription . id ,
794795 "scope" : "m.room" ,
795796 "device_id" : this . deviceId ,
797+ // DO NOT use this.memberId here since that is the state key (using application...)
798+ // But for session events we use the colon seperated userId and deviceId. The SFU will automatically
799+ // assign those values to the media participant for those versions.
800+ "membershipID" : `${ this . userId } :${ this . deviceId } ` ,
796801 expires,
797802 "m.call.intent" : this . callIntent ,
798803 ...focusObjects ,
@@ -1083,7 +1088,7 @@ export class StickyEventMembershipManager extends MembershipManager {
10831088 } ,
10841089 slot_id : slotDescriptionToId ( this . slotDescription ) ,
10851090 rtc_transports : this . rtcTransport ? [ this . rtcTransport ] : [ ] ,
1086- member : { device_id : this . deviceId , user_id : this . client . getUserId ( ) ! , id : this . memberId } ,
1091+ member : { device_id : this . deviceId , user_id : this . userId , id : this . memberId } ,
10871092 versions : [ ] ,
10881093 ...relationObject ,
10891094 } ;
0 commit comments