Class DirectRouter

  • All Implemented Interfaces:
    Router

    public class DirectRouter
    extends java.lang.Object
    implements Router
    The DirectRouter object is used to create a router that uses a single service. Typically this is used by simpler servers that wish to expose a single sub-protocol to clients.
    See Also:
    RouterContainer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String protocol
      The protocol used or null if none was specified.
      private Service service
      The service used by this router instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      DirectRouter​(Service service)
      Constructor for the DirectRouter object.
      DirectRouter​(Service service, java.lang.String protocol)
      Constructor for the DirectRouter object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Service route​(Request request, Response response)
      This is used to route an incoming request to a service if the request represents a WebSocket handshake as defined by RFC 6455.
      • Methods inherited from class java.lang.Object

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

      • service

        private final Service service
        The service used by this router instance.
      • protocol

        private final java.lang.String protocol
        The protocol used or null if none was specified.
    • Constructor Detail

      • DirectRouter

        public DirectRouter​(Service service)
        Constructor for the DirectRouter object. This is used to create an object that will select a single service. Creating an instance with this constructor means that the protocol header will not be set.
        Parameters:
        service - this is the service used by this instance
        protocol - the protocol used by this router or null
      • DirectRouter

        public DirectRouter​(Service service,
                            java.lang.String protocol)
        Constructor for the DirectRouter object. This is used to create an object that will select a single service. If the protocol specified is null then the response to the session initiation will contain null for the protocol header.
        Parameters:
        service - this is the service used by this instance
        protocol - the protocol used by this router or null
    • Method Detail

      • route

        public Service route​(Request request,
                             Response response)
        This is used to route an incoming request to a service if the request represents a WebSocket handshake as defined by RFC 6455. If the request is not a session initiating handshake then this will return a null value to allow it to be processed by some other part of the server.
        Specified by:
        route in interface Router
        Parameters:
        request - this is the request to use for routing
        response - this is the response to establish the session
        Returns:
        a service that can be used to process the session