Struct stateroom_server::Server
source · pub struct Server {
pub heartbeat_interval: Duration,
pub heartbeat_timeout: Duration,
pub port: u32,
pub ip: String,
pub static_path: Option<String>,
pub client_path: Option<String>,
}Expand description
Settings used by the server.
Fields§
§heartbeat_interval: DurationThe duration of time between server-initiated WebSocket heartbeats.
Defaults to 30 seconds.
heartbeat_timeout: DurationThe minimum amount of time between client heartbeats before a connection is dropped.
Defaults to 5 minutes.
port: u32The port to run the server on. Defaults to 8080.
ip: StringThe IP to listen on. Defaults to 0.0.0.0.
static_path: Option<String>A local filesystem path to serve static files from, or None (default).
client_path: Option<String>A local filesystem path to serve from /client, or None (default).
Implementations§
source§impl Server
impl Server
pub fn new() -> Self
pub fn with_heartbeat_interval(self, duration_seconds: u64) -> Self
pub fn with_heartbeat_timeout(self, duration_seconds: u64) -> Self
pub fn with_port(self, port: u32) -> Self
pub fn with_ip(self, ip: String) -> Self
sourcepub async fn serve_async<J>(
self,
service_factory: impl StateroomServiceFactory<ServiceActorContext, Service = J> + Send + 'static
) -> Result<()>where
J: StateroomService + Send + Sync + Unpin + 'static,
pub async fn serve_async<J>( self, service_factory: impl StateroomServiceFactory<ServiceActorContext, Service = J> + Send + 'static ) -> Result<()>where J: StateroomService + Send + Sync + Unpin + 'static,
Start a server given a StateroomService.
This function blocks until the server is terminated. While it is running, the following endpoints are available:
/(GET): return HTTP 200 if the server is running (useful as a baseline status check)/ws(GET): initiate a WebSocket connection to the stateroom service.
sourcepub fn serve<J>(
self,
service_factory: impl StateroomServiceFactory<ServiceActorContext, Service = J> + Send + 'static
) -> Result<()>where
J: StateroomService + Send + Sync + Unpin + 'static,
pub fn serve<J>( self, service_factory: impl StateroomServiceFactory<ServiceActorContext, Service = J> + Send + 'static ) -> Result<()>where J: StateroomService + Send + Sync + Unpin + 'static,
Start a server given a StateroomService.
This function blocks until the server is terminated. While it is running, the following endpoints are available:
/(GET): return HTTP 200 if the server is running (useful as a baseline status check)/ws(GET): initiate a WebSocket connection to the stateroom service.