org.springframework.web.socket.sockjs.transport.handler

## 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

    public class EventSourceTransportHandler
    extends AbstractHttpSendingTransportHandler

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

Constructors
Constructor and Description
`EventSourceTransportHandler()`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `checkSessionType(SockJsSession session)` Check whether the type of the given session matches the transport type of this `TransportHandler` where session id and the transport type are extracted from the SockJS URL.
`StreamingSockJsSession` `createSession(String sessionId, WebSocketHandler handler, Map<String,Object> attributes)` Create a new SockJS session.
`protected org.springframework.http.MediaType` `getContentType()`
`protected SockJsFrameFormat` `getFrameFormat(org.springframework.http.server.ServerHttpRequest request)`
`TransportType` `getTransportType()` 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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### EventSourceTransportHandler

    public EventSourceTransportHandler()

### Method Detail

#### getTransportType

    public TransportType getTransportType()

Description copied from interface: `TransportHandler`
Return the transport type supported by this handler.

#### getContentType

    protected org.springframework.http.MediaType getContentType()

Specified by:
  `getContentType` in class `AbstractHttpSendingTransportHandler`

#### checkSessionType

    public boolean checkSessionType(SockJsSession session)

Description copied from interface: `TransportHandler`
Check whether the type of the given session matches the transport type of this `TransportHandler` where session id and the transport type are extracted from the SockJS URL.

Returns:
  `true` if the session matches (and would therefore get accepted by `TransportHandler.handleRequest(org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse, org.springframework.web.socket.WebSocketHandler, org.springframework.web.socket.sockjs.transport.SockJsSession)`), or `false` 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 session
  `handler` - the underlying `WebSocketHandler`
  `attributes` - handshake request specific attributes
Returns:
  a new session, never `null`

#### getFrameFormat

    protected SockJsFrameFormat getFrameFormat(org.springframework.http.server.ServerHttpRequest request)

Specified by:
  `getFrameFormat` in class `AbstractHttpSendingTransportHandler`