Class GraphQlWebSocketHandler
java.lang.Object
org.springframework.web.socket.handler.AbstractWebSocketHandler
org.springframework.web.socket.handler.TextWebSocketHandler
org.springframework.graphql.server.webmvc.GraphQlWebSocketHandler
- All Implemented Interfaces:
SubProtocolCapable
,WebSocketHandler
@RegisterReflectionForBinding(GraphQlWebSocketMessage.class)
public class GraphQlWebSocketHandler
extends TextWebSocketHandler
implements SubProtocolCapable
WebSocketHandler for GraphQL based on
GraphQL Over
WebSocket Protocol and for use on a Servlet container with
spring-websocket
.- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionGraphQlWebSocketHandler
(WebGraphQlHandler graphQlHandler, HttpMessageConverter<?> converter, Duration connectionInitTimeout) Create a new instance.GraphQlWebSocketHandler
(WebGraphQlHandler graphQlHandler, HttpMessageConverter<?> converter, Duration connectionInitTimeout, Duration keepAliveDuration) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterConnectionClosed
(WebSocketSession session, CloseStatus closeStatus) void
protected void
handleTextMessage
(WebSocketSession session, TextMessage webSocketMessage) initWebSocketHttpRequestHandler
(HandshakeHandler handshakeHandler) Initialize aWebSocketHttpRequestHandler
that wraps this instance and also inserts aHandshakeInterceptor
for context propagation.Methods inherited from class org.springframework.web.socket.handler.TextWebSocketHandler
handleBinaryMessage
Methods inherited from class org.springframework.web.socket.handler.AbstractWebSocketHandler
handleMessage, handlePongMessage, handleTransportError, supportsPartialMessages
-
Constructor Details
-
GraphQlWebSocketHandler
public GraphQlWebSocketHandler(WebGraphQlHandler graphQlHandler, HttpMessageConverter<?> converter, Duration connectionInitTimeout) Create a new instance.- Parameters:
graphQlHandler
- common handler for GraphQL over WebSocket requestsconverter
- for JSON encoding and decodingconnectionInitTimeout
- how long to wait after the establishment of the WebSocket for the"connection_ini"
message from the client.
-
GraphQlWebSocketHandler
public GraphQlWebSocketHandler(WebGraphQlHandler graphQlHandler, HttpMessageConverter<?> converter, Duration connectionInitTimeout, @Nullable Duration keepAliveDuration) Create a new instance.- Parameters:
graphQlHandler
- common handler for GraphQL over WebSocket requestsconverter
- for JSON encoding and decodingconnectionInitTimeout
- how long to wait after the establishment of the WebSocket for the"connection_ini"
message from the client.keepAliveDuration
- how frequently to send ping messages when no other messages are sent- Since:
- 1.3
-
-
Method Details
-
getSubProtocols
- Specified by:
getSubProtocols
in interfaceSubProtocolCapable
-
initWebSocketHttpRequestHandler
public WebSocketHttpRequestHandler initWebSocketHttpRequestHandler(HandshakeHandler handshakeHandler) Initialize aWebSocketHttpRequestHandler
that wraps this instance and also inserts aHandshakeInterceptor
for context propagation.- Parameters:
handshakeHandler
- the handler for WebSocket handshake- Since:
- 1.1.0
-
afterConnectionEstablished
- Specified by:
afterConnectionEstablished
in interfaceWebSocketHandler
- Overrides:
afterConnectionEstablished
in classAbstractWebSocketHandler
-
handleTextMessage
protected void handleTextMessage(WebSocketSession session, TextMessage webSocketMessage) throws Exception - Overrides:
handleTextMessage
in classAbstractWebSocketHandler
- Throws:
Exception
-
afterConnectionClosed
- Specified by:
afterConnectionClosed
in interfaceWebSocketHandler
- Overrides:
afterConnectionClosed
in classAbstractWebSocketHandler
-