Class SessionDispatcher

java.lang.Object
org.simpleframework.http.socket.service.SessionDispatcher

class SessionDispatcher extends Object
The SessionDispatcher object is used to perform the opening handshake for a WebSocket session. Once the session has been established it is connected to a Service 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 Details

    • 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 Details

    • SessionDispatcher

      public SessionDispatcher(SessionBuilder builder, Router router)
      Constructor for the SessionDispatcher object. The dispatcher created will dispatch WebSocket sessions to a service using the provided Router instance.
      Parameters:
      builder - this is used to build the WebSocket session
      router - this is used to select the service
  • Method Details

    • dispatch

      public void dispatch(Request request, Response response)
      This method is used to create a dispatch a Session 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 request
      response - 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 request
      response - this is the session initiating response