Interface WebSocketDirectives

All Known Subinterfaces:
Directives
All Known Implementing Classes:
Directives$

public interface WebSocketDirectives
  • Method Details

    • extractOfferedWsProtocols

      Directive<scala.Tuple1<scala.collection.immutable.Seq<String>>> extractOfferedWsProtocols()
      Extract the list of WebSocket subprotocols as offered by the client in the Sec-WebSocket-Protocol header if this is a WebSocket request. Rejects with an ExpectedWebSocketRequestRejection, otherwise.

      Returns:
      (undocumented)
    • extractWebSocketUpgrade

      Directive<scala.Tuple1<WebSocketUpgrade>> extractWebSocketUpgrade()
      Extract the WebSocketUpgrade attribute if this is a WebSocket request. Rejects with an ExpectedWebSocketRequestRejection, otherwise.

      Returns:
      (undocumented)
    • handleWebSocketMessages

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessages(org.apache.pekko.stream.scaladsl.Flow<Message,Message,Object> handler)
      Handles WebSocket requests with the given handler and rejects other requests with an ExpectedWebSocketRequestRejection.

      Parameters:
      handler - (undocumented)
      Returns:
      (undocumented)
    • handleWebSocketMessages

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessages(org.apache.pekko.stream.scaladsl.Flow<Message,Message,Object> handler, scala.Function1<Message,Object> shouldCompress)
      Handles WebSocket requests with the given handler and selectively compresses outbound messages for which shouldCompress returns true when permessage-deflate was negotiated. The filter is evaluated synchronously once per outbound text or binary message, and the result applies to all fragments. It should be fast and non-blocking; if it throws, the WebSocket stream fails. A streamed message's complete payload and final size are not available when the filter is evaluated.

      Parameters:
      handler - (undocumented)
      shouldCompress - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleWebSocketMessagesForOptionalProtocol

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessagesForOptionalProtocol(org.apache.pekko.stream.scaladsl.Flow<Message,Message,Object> handler, scala.Option<String> subprotocol)
      Handles WebSocket requests with the given handler and rejects other requests with an ExpectedWebSocketRequestRejection.

      If the subprotocol parameter is None any WebSocket request is accepted. If the subprotocol parameter is Some(protocol) a WebSocket request is only accepted if the list of subprotocols supported by the client (as announced in the WebSocket request) contains protocol. If the client did not offer the protocol in question the request is rejected with an UnsupportedWebSocketSubprotocolRejection rejection.

      To support several subprotocols you may chain several handleWebSocketMessagesForOptionalProtocol routes.

      Parameters:
      handler - (undocumented)
      subprotocol - (undocumented)
      Returns:
      (undocumented)
    • handleWebSocketMessagesForOptionalProtocol

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessagesForOptionalProtocol(org.apache.pekko.stream.scaladsl.Flow<Message,Message,Object> handler, scala.Option<String> subprotocol, scala.Function1<Message,Object> shouldCompress)
      Handles WebSocket requests with the given handler and selectively compresses outbound messages for which shouldCompress returns true when permessage-deflate was negotiated. The filter is evaluated synchronously once per outbound text or binary message, and the result applies to all fragments. It should be fast and non-blocking; if it throws, the WebSocket stream fails. A streamed message's complete payload and final size are not available when the filter is evaluated.

      Parameters:
      handler - (undocumented)
      subprotocol - (undocumented)
      shouldCompress - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleWebSocketMessagesForProtocol

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessagesForProtocol(org.apache.pekko.stream.scaladsl.Flow<Message,Message,Object> handler, String subprotocol)
      Handles WebSocket requests with the given handler if the given subprotocol is offered in the request and rejects other requests with an ExpectedWebSocketRequestRejection or an UnsupportedWebSocketSubprotocolRejection.

      Parameters:
      handler - (undocumented)
      subprotocol - (undocumented)
      Returns:
      (undocumented)
    • handleWebSocketMessagesForProtocol

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessagesForProtocol(org.apache.pekko.stream.scaladsl.Flow<Message,Message,Object> handler, String subprotocol, scala.Function1<Message,Object> shouldCompress)
      Handles WebSocket requests with the given handler if the given subprotocol is offered and selectively compresses outbound messages for which shouldCompress returns true when permessage-deflate was negotiated. The filter is evaluated synchronously once per outbound text or binary message, and the result applies to all fragments. It should be fast and non-blocking; if it throws, the WebSocket stream fails. A streamed message's complete payload and final size are not available when the filter is evaluated.

      Parameters:
      handler - (undocumented)
      subprotocol - (undocumented)
      shouldCompress - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0