Struct jamsocket_server::Server [−][src]
pub struct Server {
pub heartbeat_interval: Duration,
pub heartbeat_timeout: Duration,
pub room_id_strategy: RoomIdStrategy,
pub port: u32,
pub shutdown_policy: ServiceShutdownPolicy,
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.
room_id_strategy: RoomIdStrategyThe method by which new rooms are created and assigned names.
port: u32The port to run the server on. Defaults to 8080.
shutdown_policy: ServiceShutdownPolicyHow the server decides to shut down a room once it is empty.
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
pub fn serve<F: JamsocketServiceFactory<ServiceActorContext>>(
self,
host_factory: F
) -> Result<()>
pub fn serve<F: JamsocketServiceFactory<ServiceActorContext>>(
self,
host_factory: F
) -> Result<()>
Start a server given a cloneable [JamsocketServiceBuilder].
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)/new_room(POST): create a new room, if not inexplicitroom creation mode./ws/{room_id}(GET): initiate a WebSocket connection to the given room. If the room does not exist and the server is inimplicitroom creation mode, it will be created.