Class EventSourceTransportHandler
java.lang.Object
org.springframework.web.socket.sockjs.transport.handler.AbstractTransportHandler
org.springframework.web.socket.sockjs.transport.handler.AbstractHttpSendingTransportHandler
org.springframework.web.socket.sockjs.transport.handler.EventSourceTransportHandler
- All Implemented Interfaces:
SockJsSessionFactory
,TransportHandler
A TransportHandler for sending messages via Server-Sent Events:
https://dev.w3.org/html5/eventsource/.
- Since:
- 4.0
- Author:
- Rossen Stoyanchev
-
Field Summary
Fields inherited from class org.springframework.web.socket.sockjs.transport.handler.AbstractTransportHandler
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
checkSessionType
(SockJsSession session) Check whether the type of the given session matches the transport type of thisTransportHandler
where session id and the transport type are extracted from the SockJS URL.createSession
(String sessionId, WebSocketHandler handler, Map<String, Object> attributes) Create a new SockJS session.protected MediaType
protected SockJsFrameFormat
getFrameFormat
(ServerHttpRequest request) Return the transport type supported by this handler.Methods inherited from class org.springframework.web.socket.sockjs.transport.handler.AbstractHttpSendingTransportHandler
getCallbackParam, handleRequest, handleRequestInternal
Methods inherited from class org.springframework.web.socket.sockjs.transport.handler.AbstractTransportHandler
getServiceConfig, initialize
-
Constructor Details
-
EventSourceTransportHandler
public EventSourceTransportHandler()
-
-
Method Details
-
getTransportType
Description copied from interface:TransportHandler
Return the transport type supported by this handler. -
getContentType
- Specified by:
getContentType
in classAbstractHttpSendingTransportHandler
-
checkSessionType
Description copied from interface:TransportHandler
Check whether the type of the given session matches the transport type of thisTransportHandler
where session id and the transport type are extracted from the SockJS URL.- Returns:
true
if the session matches (and would therefore get accepted byTransportHandler.handleRequest(org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse, org.springframework.web.socket.WebSocketHandler, org.springframework.web.socket.sockjs.transport.SockJsSession)
), orfalse
otherwise
-
createSession
public StreamingSockJsSession createSession(String sessionId, WebSocketHandler handler, Map<String, Object> attributes) Description copied from interface:SockJsSessionFactory
Create a new SockJS session.- Parameters:
sessionId
- the ID of the sessionhandler
- the underlyingWebSocketHandler
attributes
- handshake request specific attributes- Returns:
- a new session, never
null
-
getFrameFormat
- Specified by:
getFrameFormat
in classAbstractHttpSendingTransportHandler
-