Class SessionDispatcher
- java.lang.Object
-
- org.simpleframework.http.socket.service.SessionDispatcher
-
class SessionDispatcher extends java.lang.Object
TheSessionDispatcher
object is used to perform the opening handshake for a WebSocket session. Once the session has been established it is connected to aService
where frames can be sent and received. If for any reason the handshake fails this will terminated the connection with a HTTP 400 response.
-
-
Field Summary
Fields Modifier and Type Field Description private SessionBuilder
builder
This is used to create the session for the WebSocket.private Router
router
This is used to select the service to dispatch to.
-
Constructor Summary
Constructors Constructor Description SessionDispatcher(SessionBuilder builder, Router router)
Constructor for theSessionDispatcher
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispatch(Request request, Response response)
This method is used to create a dispatch aSession
to a specific service selected by a router.void
terminate(Request request, Response response)
This method is used to terminate the connection and commit the response.
-
-
-
Field Detail
-
builder
private final SessionBuilder builder
This is used to create the session for the WebSocket.
-
router
private final Router router
This is used to select the service to dispatch to.
-
-
Constructor Detail
-
SessionDispatcher
public SessionDispatcher(SessionBuilder builder, Router router)
Constructor for theSessionDispatcher
object. The dispatcher created will dispatch WebSocket sessions to a service using the providedRouter
instance.- Parameters:
builder
- this is used to build the WebSocket sessionrouter
- this is used to select the service
-
-
Method Detail
-
dispatch
public void dispatch(Request request, Response response)
This method is used to create a dispatch aSession
to a specific service selected by a router. If the session initiating handshake fails for any reason this will close the underlying TCP connection and send a HTTP 400 response back to the client.- Parameters:
request
- this is the session initiating requestresponse
- this is the session initiating response
-
terminate
public void terminate(Request request, Response response)
This method is used to terminate the connection and commit the response. Terminating the session before it has been dispatched is done when there is a protocol or an unexpected I/O error with the underlying TCP channel.- Parameters:
request
- this is the session initiating requestresponse
- this is the session initiating response
-
-