Package play.mvc

Class WebSocket

java.lang.Object
play.mvc.WebSocket

public abstract class WebSocket extends Object
A WebSocket handler.
  • Field Details

  • Constructor Details

    • WebSocket

      public WebSocket()
  • Method Details

    • apply

      public abstract CompletionStage<F.Either<Result,Flow<Message,Message,?>>> apply(Http.RequestHeader request)
      Invoke the WebSocket.
      Parameters:
      request - The request for the WebSocket.
      Returns:
      A future of either a result to reject the WebSocket connection with, or a Flow to handle the WebSocket.
    • json

      public static <In, Out> WebSocket.MappedWebSocketAcceptor<In,Out> json(Class<In> in)
      Acceptor for JSON WebSockets.
      Type Parameters:
      In - The websocket's input type (what it receives from clients)
      Out - The websocket's output type (what it writes to clients)
      Parameters:
      in - The class of the incoming messages, used to decode them from the JSON.
      Returns:
      The WebSocket acceptor.