Class SessionBuilder


  • class SessionBuilder
    extends java.lang.Object
    The SessionBuilder object is used to create sessions for connected WebSockets. Before the session is created a response is sent back to the connected client. If for some reason the session is not valid or does not conform to the requirements of RFC 6455 then a HTTP 400 response code is sent and the TCP channel is closed.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long ping
      This is the frequency the server should send out ping frames.
      private Reactor reactor
      This is the reactor used to register for I/O notifications.
      private Scheduler scheduler
      This is the scheduler that is used to ping WebSocket sessions.
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionBuilder​(Scheduler scheduler, Reactor reactor, long ping)
      Constructor for the SessionBuilder object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Session create​(Request request, Response response)
      This is used to create a WebSocket session.
      • Methods inherited from class java.lang.Object

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

      • scheduler

        private final Scheduler scheduler
        This is the scheduler that is used to ping WebSocket sessions.
      • reactor

        private final Reactor reactor
        This is the reactor used to register for I/O notifications.
      • ping

        private final long ping
        This is the frequency the server should send out ping frames.
    • Constructor Detail

      • SessionBuilder

        public SessionBuilder​(Scheduler scheduler,
                              Reactor reactor,
                              long ping)
        Constructor for the SessionBuilder object. This is used to create sessions using the request and response associated with the WebSocket opening handshake.
        Parameters:
        scheduler - this is the shared thread pool used for pinging
        reactor - this is used to check for I/O notifications
        ping - this is the frequency to send out ping frames
    • Method Detail

      • create

        public Session create​(Request request,
                              Response response)
                       throws java.lang.Exception
        This is used to create a WebSocket session. If at any point there is an error creating the session the underlying TCP connection is closed and a Session is returned regardless.
        Parameters:
        request - this is the request associated with this session
        response - this is the response associated with this session
        Returns:
        this returns the session associated with the WebSocket
        Throws:
        java.lang.Exception