Interface WebSocketUpgrade

All Superinterfaces:
WebSocketUpgrade
All Known Implementing Classes:
UpgradeToWebSocketLowLevel

public interface WebSocketUpgrade extends WebSocketUpgrade
An attribute that will be added to an WebSocket upgrade HttpRequest that enables a request handler to upgrade this connection to a WebSocket connection and registers a WebSocket handler.

This is a low-level API. You might want to use handleWebSocketMessages instead as documented at https://pekko.apache.org/docs/pekko-http/current/server-side/websocket-support.html#routing-support

  • Method Details

    • createScalaFlow

      org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<Message,Message>,org.apache.pekko.NotUsed> createScalaFlow(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Message>,?> inSink, org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<Message>,?> outSource)
      Java API

      Parameters:
      inSink - (undocumented)
      outSource - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • getRequestedProtocols

      Iterable<String> getRequestedProtocols()
      Java API
      Specified by:
      getRequestedProtocols in interface WebSocketUpgrade
      Returns:
      (undocumented)
    • handleMessages

      HttpResponse handleMessages(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<Message,Message>,Object> handlerFlow, scala.Option<String> subprotocol)
      The high-level interface to create a WebSocket server based on "messages".

      Returns a response to return in a request handler that will signal the low-level HTTP implementation to upgrade the connection to WebSocket and use the supplied handler to handle incoming WebSocket messages.

      Optionally, a subprotocol out of the ones requested by the client can be chosen.

      Parameters:
      handlerFlow - (undocumented)
      subprotocol - (undocumented)
      Returns:
      (undocumented)
    • handleMessages

      HttpResponse handleMessages(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<Message,Message>,Object> handlerFlow, scala.Option<String> subprotocol, boolean compressionEnabled)
      The high-level interface to create a WebSocket server based on "messages".

      Returns a response to return in a request handler that will signal the low-level HTTP implementation to upgrade the connection to WebSocket and use the supplied handler to handle incoming WebSocket messages.

      Optionally, a subprotocol out of the ones requested by the client can be chosen. The compressionEnabled flag allows declining negotiated WebSocket compression for this accepted WebSocket.

      Parameters:
      handlerFlow - (undocumented)
      subprotocol - (undocumented)
      compressionEnabled - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<Message,Message>,?> handlerFlow)
      Java API
      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      handlerFlow - (undocumented)
      Returns:
      (undocumented)
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<Message,Message>,?> handlerFlow, boolean compressionEnabled)
      Java API

      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      handlerFlow - (undocumented)
      compressionEnabled - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<Message,Message>,?> handlerFlow, String subprotocol)
      Java API
      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      handlerFlow - (undocumented)
      subprotocol - (undocumented)
      Returns:
      (undocumented)
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<Message,Message>,?> handlerFlow, String subprotocol, boolean compressionEnabled)
      Java API

      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      handlerFlow - (undocumented)
      subprotocol - (undocumented)
      compressionEnabled - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Message>,?> inSink, org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<Message>,?> outSource)
      Java API
      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      inSink - (undocumented)
      outSource - (undocumented)
      Returns:
      (undocumented)
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Message>,?> inSink, org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<Message>,?> outSource, boolean compressionEnabled)
      Java API

      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      inSink - (undocumented)
      outSource - (undocumented)
      compressionEnabled - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Message>,?> inSink, org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<Message>,?> outSource, String subprotocol)
      Java API

      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      inSink - (undocumented)
      outSource - (undocumented)
      subprotocol - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleMessagesWith

      HttpResponse handleMessagesWith(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Message>,?> inSink, org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<Message>,?> outSource, String subprotocol, boolean compressionEnabled)
      Java API

      Specified by:
      handleMessagesWith in interface WebSocketUpgrade
      Parameters:
      inSink - (undocumented)
      outSource - (undocumented)
      subprotocol - (undocumented)
      compressionEnabled - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • handleMessagesWithSinkSource

      HttpResponse handleMessagesWithSinkSource(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Message>,Object> inSink, org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<Message>,Object> outSource, scala.Option<String> subprotocol)
      The high-level interface to create a WebSocket server based on "messages".

      Returns a response to return in a request handler that will signal the low-level HTTP implementation to upgrade the connection to WebSocket and use the supplied inSink to consume messages received from the client and the supplied outSource to produce message to sent to the client.

      Optionally, a subprotocol out of the ones requested by the client can be chosen.

      Parameters:
      inSink - (undocumented)
      outSource - (undocumented)
      subprotocol - (undocumented)
      Returns:
      (undocumented)
    • handleMessagesWithSinkSource

      HttpResponse handleMessagesWithSinkSource(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Message>,Object> inSink, org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<Message>,Object> outSource, scala.Option<String> subprotocol, boolean compressionEnabled)
      The high-level interface to create a WebSocket server based on "messages".

      Returns a response to return in a request handler that will signal the low-level HTTP implementation to upgrade the connection to WebSocket and use the supplied inSink to consume messages received from the client and the supplied outSource to produce message to sent to the client.

      Optionally, a subprotocol out of the ones requested by the client can be chosen. The compressionEnabled flag allows declining negotiated WebSocket compression for this accepted WebSocket.

      Parameters:
      inSink - (undocumented)
      outSource - (undocumented)
      subprotocol - (undocumented)
      compressionEnabled - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0
    • requestedProtocols

      scala.collection.immutable.Seq<String> requestedProtocols()
      A sequence of protocols the client accepts.

      See http://tools.ietf.org/html/rfc6455#section-1.9

      Returns:
      (undocumented)