Sync from GitHub main #1

Open
nomad wants to merge 145 commits from sync/from-github into main
Showing only changes of commit b4fe87e1ca - Show all commits
+8 -1
View File
@@ -14,6 +14,7 @@ class ClientSession:
connected_at: float connected_at: float
last_packet_at: float | None = None last_packet_at: float | None = None
last_transform: dict[str, Any] | None = None last_transform: dict[str, Any] | None = None
last_transform_monotonic: float | None = None
packets_received: int = 0 packets_received: int = 0
packets_sent: int = 0 packets_sent: int = 0
packets_broadcast: int = 0 packets_broadcast: int = 0
@@ -32,9 +33,15 @@ class ClientSession:
self.packets_received += 1 self.packets_received += 1
return self.packets_received return self.packets_received
def record_transform(self, packet: dict[str, Any]) -> None: def record_transform(self, packet: dict[str, Any], accepted_monotonic: float | None = None) -> None:
with self._lock: with self._lock:
self.last_transform = dict(packet) self.last_transform = dict(packet)
self.last_transform_monotonic = accepted_monotonic
def get_last_transform_anchor(self) -> tuple[dict[str, Any] | None, float | None]:
with self._lock:
transform = dict(self.last_transform) if self.last_transform is not None else None
return transform, self.last_transform_monotonic
def record_sent(self, *, broadcast: bool = False) -> None: def record_sent(self, *, broadcast: bool = False) -> None:
with self._lock: with self._lock: