Interface WebSocketDirectives

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

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 {@link Sec-WebSocket-Protocol} header if this is a WebSocket request. Rejects with an ExpectedWebSocketRequestRejection, otherwise.

      Returns:
      (undocumented)
    • extractUpgradeToWebSocket

      Directive<scala.Tuple1<UpgradeToWebSocket>> extractUpgradeToWebSocket()
      Deprecated.
      use `extractWebSocketUpgrade` instead. Since 10.2.0.
      Extract the UpgradeToWebSocket header if existent. 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(akka.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)
    • handleWebSocketMessagesForOptionalProtocol

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessagesForOptionalProtocol(akka.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)
    • handleWebSocketMessagesForProtocol

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> handleWebSocketMessagesForProtocol(akka.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)