Class ServiceDispatcher

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

class ServiceDispatcher extends 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 Details

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

    • ServiceDispatcher

      public ServiceDispatcher(Router router, int threads) throws 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:
      IOException
    • ServiceDispatcher

      public ServiceDispatcher(Router router, int threads, long ping) throws 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:
      IOException
  • 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