pub struct ServerBuilder { /* private fields */ }Expand description
Builder for configuring a Server.
use ghost_sync::Server;
let server = Server::builder()
.bind("0.0.0.0:7777")
.max_clients(128)
.max_payload(128 * 1024)
.build();Implementations§
Source§impl ServerBuilder
impl ServerBuilder
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub fn bind(self, addr: impl Into<String>) -> Self
pub fn bind(self, addr: impl Into<String>) -> Self
Set the bind address (e.g., "0.0.0.0:7777").
Sourcepub fn max_clients(self, n: usize) -> Self
pub fn max_clients(self, n: usize) -> Self
Set max concurrent clients. Connections beyond this are rejected.
Sourcepub fn max_payload(self, n: usize) -> Self
pub fn max_payload(self, n: usize) -> Self
Set max incoming payload size in bytes. Frames larger than this are rejected.
Sourcepub fn idle_timeout(self, d: Duration) -> Self
pub fn idle_timeout(self, d: Duration) -> Self
Disconnect clients that send nothing for this duration.
Any frame (including Pong) resets this timer. This is separate from
ping-based liveness — see ping_interval.
Sourcepub fn ping_interval(self, d: Duration) -> Self
pub fn ping_interval(self, d: Duration) -> Self
How often the server pings clients. Pong deadline is one full
ping_interval — if no Pong arrives before the next tick, the
client is disconnected. This is separate from read inactivity —
see idle_timeout.
Sourcepub fn channel_capacity(self, n: usize) -> Self
pub fn channel_capacity(self, n: usize) -> Self
Per-client write channel capacity. Frames are dropped when full
(with on_backpressure hook). Higher values buffer more for bursty
games, lower values keep latency tight. Default: 1024.
Sourcepub fn handler(self, h: impl ServerHandler) -> Self
pub fn handler(self, h: impl ServerHandler) -> Self
Set a custom event handler for lifecycle hooks.
Sourcepub fn build(self) -> Server
pub fn build(self) -> Server
Build the server. Call Server::run to start accepting connections.