Class ServiceDispatcher


  • class ServiceDispatcher
    extends java.lang.Object
    The ServiceDispatcher 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 build the sessions from the handshake request.
      private SessionDispatcher dispatcher
      This is the session dispatcher used to dispatch the session.
      private Reactor reactor
      This is used to notify of read events on the TCP channel.
      private Scheduler scheduler
      This is used asynchronously read frames from the TCP channel.
    • Constructor Summary

      Constructors 
      Constructor Description
      ServiceDispatcher​(Router router, int threads)
      Constructor for the ServiceDispatcher object.
      ServiceDispatcher​(Router router, int threads, long ping)
      Constructor for the ServiceDispatcher 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 a Session to a specific service selected by a router.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • dispatcher

        private final SessionDispatcher dispatcher
        This is the session dispatcher used to dispatch the session.
      • builder

        private final SessionBuilder builder
        This is used to build the sessions from the handshake request.
      • scheduler

        private final Scheduler scheduler
        This is used asynchronously read frames from the TCP channel.
      • reactor

        private final Reactor reactor
        This is used to notify of read events on the TCP channel.
    • Constructor Detail

      • ServiceDispatcher

        public ServiceDispatcher​(Router router,
                                 int threads)
                          throws java.io.IOException
        Constructor for the ServiceDispatcher object. The dispatcher created will dispatch WebSocket sessions to a service using the provided Router instance.
        Parameters:
        router - this is the router used to select a service
        threads - this is the number of threads to use
        Throws:
        java.io.IOException
      • ServiceDispatcher

        public ServiceDispatcher​(Router router,
                                 int threads,
                                 long ping)
                          throws java.io.IOException
        Constructor for the ServiceDispatcher object. The dispatcher created will dispatch WebSocket sessions to a service using the provided Router instance.
        Parameters:
        router - this is the router used to select a service
        threads - this is the number of threads to use
        ping - this is the frequency used to send ping frames
        Throws:
        java.io.IOException
    • 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