Skip to content

Conversation

toger5
Copy link
Contributor

@toger5 toger5 commented Sep 23, 2025

Depends on #5028

This PR adds support for sticky events in the MatrixRTCSession:

  • send sticky events instead of state events
  • update the call memberships based on sticky events instead of membership changes.
  • resend the current membership if the sticky event times out with an updated expiration ts (This is not the final solution. the sticky event timeout in iteself is enough. no expiration needed on the event content)

@toger5 toger5 changed the title Toger5/sticky-events Sticky Events support for matrixRTC (MSC4354) Sep 23, 2025
@toger5 toger5 force-pushed the toger5/sticky-events branch 2 times, most recently from 4ff6fb9 to dde4abb Compare September 23, 2025 17:57
@toger5 toger5 changed the base branch from voip-team/multi-SFU to develop September 23, 2025 17:57
@kegsay kegsay self-requested a review September 24, 2025 13:00
Copy link
Contributor Author

@toger5 toger5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temp review

Comment on lines +233 to +237
interface SessionMembershipsForRoomOpts {
listenForStickyEvents: boolean;
listenForMemberStateEvents: boolean;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we really want to make this configurable?
It would be great if we can just always make it listen to this?
Not sure its possible however...
Do you have an idea for a case where "always on" would break?

}

this.client.on(ClientEvent.Room, this.onRoom);
this.client.on(ClientEvent.Event, this.onEvent);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this in combination with:
this.roomSubset.on(RoomEvent.StickyEvents, this.onStickyEventUpdate);
will result in two calls to recalculateSessionMembers once via refreshRoom -> onRTCSessionMemberUpdate -> recalculateSessionMembers And a second time throughonStickyEventUpdate->`recalculateSessionMembers.

Or is there any check so one of them gets ignored?

A possible solution would be to check if the associated room already has a session (in onRoom) and if so, we do not call refresh room? So it only gets called on creating a new session?

This logic maybe should be applied to all of this file. refreshRoom should be: refreshSessionStore/Map and than we expect the session itself to listen to all the evnt updates. Listeners in the SessionManager only are responsible to find out if new sessions need to be created!

@Half-Shot Half-Shot mentioned this pull request Oct 1, 2025
4 tasks
@Half-Shot Half-Shot force-pushed the toger5/sticky-events branch from 34be9c8 to e3157e6 Compare October 3, 2025 12:51
@Half-Shot Half-Shot force-pushed the toger5/sticky-events branch from e36ff71 to 946c20a Compare October 7, 2025 10:33
@toger5
Copy link
Contributor Author

toger5 commented Oct 7, 2025

I am relativly sure we are doing the right thing.
But I want to write down (and get confirmation) that we do expire call memberships if the sticky duration times out

  • Once a sticky event expires we emit the sticky map change action
  • if that action is emitted we recalculate the room
  • public static sessionMembershipsForSlot will get called as a consequence
  • this method will compute all the memberships based on the CURRENT SET OF matrix sticky events? (so if some event times out, it will not be in the CURRENT SET OF matrix sticky and hence will not be aprt of the memberships anymore?

@toger5 toger5 changed the title Sticky Events support for matrixRTC (MSC4354) [MatrixRTC] Sticky Events support (MSC4354) Oct 7, 2025
Base automatically changed from hs/sticky-events to develop October 7, 2025 17:40
});
});

describe("StickyEventMembershipManager", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test suite needs much expanding really. This only touches the joins, we really need to test other behaviours.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that this class does really is overwriting send and send delay + makeMyMembership. All this is covered in the join test.
There is also the error logging method... but that not being tested sounds fairly save.

All the rest of the behavior of the Memberhsip Manager stays as it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything specific you have in mind?

};

protected actionUpdateFromErrors(e: unknown, t: MembershipActionType, m: string): ActionUpdate | undefined {
const mappedMethod = new Map([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just make this a static const, which gives you types for free and stops us creating a new Map each time we call this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that makes sense.

Copy link
Contributor

@Half-Shot Half-Shot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@toger5 toger5 marked this pull request as ready for review October 9, 2025 15:57
Signed-off-by: Timo K <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants