flatland-client-lib 0.1.0

Flatland3 remote game client library (TCP session, bots, game state)
Documentation
//! Client-side session events (decoded from server messages).

use flatland_protocol::{EntityId, Intent, Seq, SessionId, Snapshot, Tick, TickDelta};

#[derive(Debug, Clone)]
pub enum SessionEvent {
    Welcome {
        session_id: SessionId,
        entity_id: EntityId,
        snapshot: Snapshot,
    },
    Tick(TickDelta),
    IntentAck {
        entity_id: EntityId,
        seq: Seq,
        tick: Tick,
    },
    Disconnected,
}

/// Gameplay session handle (remote TCP or in-process worker).
#[async_trait::async_trait]
pub trait PlayConnection: Send {
    fn session_id(&self) -> SessionId;
    fn entity_id(&self) -> EntityId;
    async fn submit_intent(&self, intent: Intent) -> anyhow::Result<()>;
    fn try_next_event(&mut self) -> Option<SessionEvent>;
    async fn next_event(&mut self) -> Option<SessionEvent>;
    fn disconnect(&self);
}