Package play.mvc
Class WebSocket
- Object
-
- play.mvc.WebSocket
-
public abstract class WebSocket extends Object
A WebSocket handler.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WebSocket.MappedWebSocketAcceptor<In,Out>
Utility class for creating WebSockets.
-
Field Summary
Fields Modifier and Type Field Description static WebSocket.MappedWebSocketAcceptor<ByteString,ByteString>
Binary
Acceptor for binary WebSockets.static WebSocket.MappedWebSocketAcceptor<com.fasterxml.jackson.databind.JsonNode,com.fasterxml.jackson.databind.JsonNode>
Json
Acceptor for JSON WebSockets.static WebSocket.MappedWebSocketAcceptor<String,String>
Text
Acceptor for text WebSockets.
-
Constructor Summary
Constructors Constructor Description WebSocket()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract CompletionStage<F.Either<Result,Flow<Message,Message,?>>>
apply(Http.RequestHeader request)
Invoke the WebSocket.static <In,Out>
WebSocket.MappedWebSocketAcceptor<In,Out>json(Class<In> in)
Acceptor for JSON WebSockets.
-
-
-
Field Detail
-
Text
public static final WebSocket.MappedWebSocketAcceptor<String,String> Text
Acceptor for text WebSockets.
-
Binary
public static final WebSocket.MappedWebSocketAcceptor<ByteString,ByteString> Binary
Acceptor for binary WebSockets.
-
Json
public static final WebSocket.MappedWebSocketAcceptor<com.fasterxml.jackson.databind.JsonNode,com.fasterxml.jackson.databind.JsonNode> Json
Acceptor for JSON WebSockets.
-
-
Method Detail
-
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.
-
-