Class SessionDispatcher
- java.lang.Object
-
- org.simpleframework.http.socket.service.SessionDispatcher
-
class SessionDispatcher extends java.lang.ObjectTheSessionDispatcherobject is used to perform the opening handshake for a WebSocket session. Once the session has been established it is connected to aServicewhere 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 SessionBuilderbuilderThis is used to create the session for the WebSocket.private RouterrouterThis is used to select the service to dispatch to.
-
Constructor Summary
Constructors Constructor Description SessionDispatcher(SessionBuilder builder, Router router)Constructor for theSessionDispatcherobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispatch(Request request, Response response)This method is used to create a dispatch aSessionto a specific service selected by a router.voidterminate(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 theSessionDispatcherobject. The dispatcher created will dispatch WebSocket sessions to a service using the providedRouterinstance.- 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 aSessionto 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
-
-