Skip to main content

start_with

Function start_with 

Source
pub async fn start_with<S, Err>(
    req: &HttpRequest,
    subprotocol: Option<&str>,
    f: impl IntoService<S, WsSink, DispatchItem<WsSink>>,
) -> Result<(), WsError<Err>>
where S: Service<WsSink, DispatchItem<WsSink>, Res = Option<Message>, Error = WsError<Err>> + 'static, S::Error: Debug, Err: 'static,
Expand description

Start websocket service handling raw DispatchItem messages requiring manual control/stop logic, including the chosen subprotocol in the response.

If subprotocol is Some, the Sec-Websocket-Protocol header will be included in the response with the chosen protocol. The protocol must be a valid HTTP token offered by the client. If None, the header is omitted.

If the handshake fails for an upgrade request, the handshake error response is sent and the connection is closed.