flatland_client_lib/
session.rs1use flatland_protocol::{EntityId, Intent, Seq, SessionId, Snapshot, Tick, TickDelta};
4
5#[derive(Debug, Clone)]
6pub enum SessionEvent {
7 Welcome {
8 session_id: SessionId,
9 entity_id: EntityId,
10 snapshot: Snapshot,
11 },
12 Tick(TickDelta),
13 IntentAck {
14 entity_id: EntityId,
15 seq: Seq,
16 tick: Tick,
17 },
18 Disconnected,
19}
20
21#[async_trait::async_trait]
23pub trait PlayConnection: Send {
24 fn session_id(&self) -> SessionId;
25 fn entity_id(&self) -> EntityId;
26 async fn submit_intent(&self, intent: Intent) -> anyhow::Result<()>;
27 fn try_next_event(&mut self) -> Option<SessionEvent>;
28 async fn next_event(&mut self) -> Option<SessionEvent>;
29 fn disconnect(&self);
30}