Track last accepted transform timing
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user