1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! 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
//!
//! ```text
//! 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:
//!
//! ```toml
//! optic = { git = "..", features = ["online"] }
//! ```
//!
//! Then configure in your [`GameBuilder`](optic_loop::GameBuilder):
//!
//! ```ignore
//! use optic_engine::*;
//!
//! let game = GameBuilder::new()
//! .with_network(NetworkConfig::host(7777))
//! .build(App)?
//! .enable_networking();
//! ```
pub use NetworkHandle;
pub use *;
pub use *;