When state says you've left ongoing call, rejoin
When receiving a state change that says you are no longer a member of a RTC session that you are actually still participating in, send another state event to put yourself back in the session membership.
This can happen when an administrator overwrites your call membership event (which is allowed even with MSC3757's restrictions on state), or if your delayed disconnection event (via MSC4140) timed out before your client could send a heartbeat to delay it further.
Signed-off-by: Andrew Ferrazzutti [email protected]
Checklist
- [ ] Tests written for new code (and old code if feasible).
- [x] New or updated
public/exportedsymbols have accurate TSDoc documentation. - [x] Linter and other CI checks pass.
- [x] Sign-off given on the changes (see CONTRIBUTING.md).
Marking as draft until test coverage is added.
Local testing is also hitting some strange behaviour.
This doesn't yet fully work in widget mode + Element Web (and potentially other clients). EW terminates the widget when it detects that there are no members left in a call. So, if there's only one person left in a call and their membership is lost (such as by a missed heartbeat), EW will close the widget before EC has a chance to restore the membership.
A naive solution could be to make EW simply wait a few seconds for an "empty" session to become non-empty. Ideally it could examine Livekit state (if that's even possible).
But EW does need to know when a call is empty, because AFAICT that's how it clears the entry in the room preview bar.
I've made this depend on https://github.com/matrix-org/matrix-js-sdk/pull/4494 because without it, attempts to restore membership state are likely to get rate-limited.
Albeit not fully working for embedded mode, this is still a step in the right direction IMO.