Class RouterContainer

java.lang.Object
org.simpleframework.http.socket.service.RouterContainer
All Implemented Interfaces:
Container

public class RouterContainer extends Object implements Container
The RouterContainer is used to route requests that satisfy a WebSocket opening handshake to a specific service. Each request intercepted by this Container implementation is examined for opening handshake criteria as specified by RFC 6455, and if it contains the required information it is router to a specific service using a Router implementation. If the request does not contain the required criteria it is handled by an internal container delegate.
See Also:
  • Field Details

    • dispatcher

      private final ServiceDispatcher dispatcher
      This is the service dispatcher used to dispatch requests.
    • container

      private final Container container
      This is the container used to handle traditional requests.
    • router

      private final Router router
      This is the router used to select specific services.
  • Constructor Details

    • RouterContainer

      public RouterContainer(Container container, Router router, int threads) throws IOException
      Constructor for the RouterContainer object. This requires a container to delegate traditional requests to and a Router implementation which can be used to select a service to dispatch a WebSocket session to.
      Parameters:
      container - this is the container to delegate to
      router - this is the router used to select services
      threads - this contains the number of threads to use
      Throws:
      IOException
    • RouterContainer

      public RouterContainer(Container container, Router router, int threads, long ping) throws IOException
      Constructor for the RouterContainer object. This requires a container to delegate traditional requests to and a Router implementation which can be used to select a service to dispatch a WebSocket session to.
      Parameters:
      container - this is the container to delegate to
      router - this is the router used to select services
      threads - this contains the number of threads to use
      ping - this is the frequency to send ping frames with
      Throws:
      IOException
  • Method Details

    • handle

      public void handle(Request req, Response resp)
      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. All traditional requests that do not represent an WebSocket opening handshake are dispatched to the internal container.
      Specified by:
      handle in interface Container
      Parameters:
      req - the request that contains the client HTTP message
      resp - the response used to deliver the server response