forked from Foxyz/sync_replay_project
Restructure step 1: lasting identity, presence and protocol 16
Server and core: version ranges on both sides with a coded refusal; a client id maps to the same member and token for the server's life; a drop is `gone` for a 10-minute grace keeping ready, presence, queue items, relay and avatar; `bye` leaves at once; ordered takeover (seq, replaced/stale); presence joining/in/away/gone with one PresencePolicy; joiners never pause playback and hold a held gate at most ~15 s; state.hold; feed ids, seq and replay; the relay lives through its source's grace and continues on re-dial; queue `by` lasting, auto items and cancel; MediaRef carried; client ids never logged. App: persisted client id and seq; Connection with unstable/lost/ replaced states, backoff with jitter, no lost/back pair per flap; a drop keeps the session (state, player, media, relay source); presence in the strip and members card; sit out = away intent; feed matched by id; auto sit-out (idle when not playing, minimised for a while; never when alone) replaces auto-unready; bye on close and Leave, not on update restart; relay source re-dials through its grace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
51c1c5ab78
commit
9f2586b7ff
85 files changed
+5198
-1902
No files matched your search
@@ -1,5 +1,3 @@
|
||||
// restructure: rewrite in step 1 (Connection + Identity + Presence): a
|
||||
// socket close no longer removes the member (explicit `bye`, grace).
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
@@ -74,14 +72,22 @@ void main() {
|
||||
await server.stop();
|
||||
});
|
||||
|
||||
test('clean client close removes member within seconds, not timeout',
|
||||
() async {
|
||||
test('a clean close is not a leave: the member is gone at once, kept', () async {
|
||||
final client = await _ProbeClient.hello(server.boundPort, 'alice');
|
||||
await _pollBool(
|
||||
() => server.hub.engine.members.length == 1, 'join visible');
|
||||
await _pollBool(() => server.hub.engine.members.length == 1, 'join visible');
|
||||
await client.ws.close();
|
||||
await _pollBool(
|
||||
() => server.hub.engine.members.isEmpty, 'member removed');
|
||||
await _pollBool(() => server.hub.engine.members.values.single.presence == Presence.gone, 'gone');
|
||||
expect(server.session.tokens, hasLength(1), reason: 'its token works through the grace');
|
||||
expect(server.hub.sockets, isEmpty);
|
||||
});
|
||||
|
||||
test('bye leaves at once: member, token and socket go', () async {
|
||||
final client = await _ProbeClient.hello(server.boundPort, 'alice');
|
||||
await _pollBool(() => server.hub.engine.members.length == 1, 'join visible');
|
||||
client.ws.add(jsonEncode(const ByeMessage().toJson()));
|
||||
final outcome = await client.closed.future.timeout(const Duration(seconds: 5));
|
||||
expect(outcome, contains('code=${CloseCodes.left}'));
|
||||
expect(server.hub.engine.members, isEmpty);
|
||||
expect(server.session.tokens, isEmpty);
|
||||
expect(server.hub.sockets, isEmpty);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user