Struct socketioxide::SocketIoBuilder
source · pub struct SocketIoBuilder<A: Adapter = LocalAdapter> { /* private fields */ }
Expand description
A builder to create a SocketIo
instance.
It contains everything to configure the socket.io server with a SocketIoConfig
.
It can be used to build either a Tower Layer
or a Service
.
Implementations§
source§impl<A: Adapter> SocketIoBuilder<A>
impl<A: Adapter> SocketIoBuilder<A>
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SocketIoBuilder
with default config
sourcepub fn req_path(self, req_path: impl Into<Cow<'static, str>>) -> Self
pub fn req_path(self, req_path: impl Into<Cow<'static, str>>) -> Self
The path to listen for socket.io requests on.
Defaults to “/socket.io”.
sourcepub fn ping_interval(self, ping_interval: Duration) -> Self
pub fn ping_interval(self, ping_interval: Duration) -> Self
The interval at which the server will send a ping packet to the client.
Defaults to 25 seconds.
sourcepub fn ping_timeout(self, ping_timeout: Duration) -> Self
pub fn ping_timeout(self, ping_timeout: Duration) -> Self
The amount of time the server will wait for a ping response from the client before closing the connection.
Defaults to 20 seconds.
sourcepub fn max_buffer_size(self, max_buffer_size: usize) -> Self
pub fn max_buffer_size(self, max_buffer_size: usize) -> Self
The maximum number of packets that can be buffered per connection before being emitted to the client.
If the buffer if full the emit()
method will return an error
Defaults to 128 packets.
sourcepub fn max_payload(self, max_payload: u64) -> Self
pub fn max_payload(self, max_payload: u64) -> Self
The maximum size of a payload in bytes.
If a payload is bigger than this value the emit()
method will return an error.
Defaults to 100 kb.
sourcepub fn transports<const N: usize>(self, transports: [TransportType; N]) -> Self
pub fn transports<const N: usize>(self, transports: [TransportType; N]) -> Self
Allowed transports on this server
The transports
array should have a size of 1 or 2
Defaults to :
[TransportType::Polling, TransportType::Websocket]
sourcepub fn ack_timeout(self, ack_timeout: Duration) -> Self
pub fn ack_timeout(self, ack_timeout: Duration) -> Self
The amount of time the server will wait for an acknowledgement from the client before closing the connection.
Defaults to 5 seconds.
sourcepub fn connect_timeout(self, connect_timeout: Duration) -> Self
pub fn connect_timeout(self, connect_timeout: Duration) -> Self
The amount of time before disconnecting a client that has not successfully joined a namespace.
Defaults to 45 seconds.
sourcepub fn with_config(self, config: SocketIoConfig) -> Self
pub fn with_config(self, config: SocketIoConfig) -> Self
Sets a custom SocketIoConfig
created previously for this SocketIoBuilder
sourcepub fn with_adapter<B: Adapter>(self) -> SocketIoBuilder<B>
pub fn with_adapter<B: Adapter>(self) -> SocketIoBuilder<B>
Sets a custom Adapter
for this SocketIoBuilder
sourcepub fn with_state<S: Send + Sync + 'static>(self, state: S) -> Self
Available on crate feature state
only.
pub fn with_state<S: Send + Sync + 'static>(self, state: S) -> Self
state
only.sourcepub fn build_layer(self) -> (SocketIoLayer<A>, SocketIo<A>)
pub fn build_layer(self) -> (SocketIoLayer<A>, SocketIo<A>)
Builds a SocketIoLayer
and a SocketIo
instance
The layer can be used as a tower layer
sourcepub fn build_svc(self) -> (SocketIoService<NotFoundService>, SocketIo)
pub fn build_svc(self) -> (SocketIoService<NotFoundService>, SocketIo)
Builds a SocketIoService
and a SocketIo
instance
This service will be a standalone service that return a 404 error for every non-socket.io request It can be used as a hyper service
sourcepub fn build_with_inner_svc<S: Clone>(
self,
svc: S
) -> (SocketIoService<S>, SocketIo)
pub fn build_with_inner_svc<S: Clone>( self, svc: S ) -> (SocketIoService<S>, SocketIo)
Builds a SocketIoService
and a SocketIo
instance with an inner service
It can be used as a hyper service