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