Class SessionDispatcher


  • class SessionDispatcher
    extends java.lang.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 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.
    • 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 a Session 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 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 Detail

      • 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