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: Duration

The duration of time between server-initiated WebSocket heartbeats.

Defaults to 30 seconds.

heartbeat_timeout: Duration

The minimum amount of time between client heartbeats before a connection is dropped.

Defaults to 5 minutes.

room_id_strategy: RoomIdStrategy

The method by which new rooms are created and assigned names.

port: u32

The port to run the server on. Defaults to 8080.

shutdown_policy: ServiceShutdownPolicy

How 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

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 in explicit room creation mode.
  • /ws/{room_id} (GET): initiate a WebSocket connection to the given room. If the room does not exist and the server is in implicit room creation mode, it will be created.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more