Skip to main content

Crate optic_online

Crate optic_online 

Source
Expand description

UDP networking for the Optic engine.

Runs a tokio runtime on a dedicated background thread, communicating with the main thread via mpsc channels. All I/O is non-blocking from the game loop’s perspective.

§Architecture

Game loop (main thread)          Network thread
┌────────────────────┐          ┌─────────────────────┐
│ NetworkHandle      │─tx cmd──▶│ tokio runtime        │
│   .send_to()      │          │   UdpSocket          │
│   .send_all()     │◀─data────│   heartbeat keepalive│
│   .poll()         │◀─events──│   peer lifecycle      │
└────────────────────┘          └─────────────────────┘

§Feature flag

This crate is optional. Enable it with the online feature:

optic = { git = "..", features = ["online"] }

Then configure in your GameBuilder:

use optic_engine::*;

let game = GameBuilder::new()
    .with_network(NetworkConfig::host(7777))
    .build(App)?
    .enable_networking();

Re-exports§

pub use handle::NetworkHandle;
pub use config::*;
pub use peer::*;

Modules§

channels
config
handle
peer
transport