Class WebsocketPingerService

    • Field Detail

      • DEFAULT_PING_INTERVAL

        public static final int DEFAULT_PING_INTERVAL
        Majority of proxy and NAT routers have timeout of at least 60s.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_MALFORMED_PONG_COUNT

        public static final int DEFAULT_MAX_MALFORMED_PONG_COUNT
        Arbitrarily chosen number.
        See Also:
        Constant Field Values
    • Constructor Detail

      • WebsocketPingerService

        public WebsocketPingerService​(int pingIntervalSeconds,
                                      int maxMalformedPongCount)
        Configures and starts the service.
        Parameters:
        pingIntervalSeconds - how often to ping all connections.
        maxMalformedPongCount - limit after which a given connection is closed. Each valid, timely pong resets connection's counter. Pongs received after pingIntervalSeconds count as malformed.
    • Method Detail

      • getConnectionsSize

        public int getConnectionsSize()
        Returns the number of currently registered connections.
      • stop

        public ConcurrentMap<Session,​pl.morgwai.base.servlet.utils.WebsocketPingerService.PingPongPlayer> stop()
        Stops the service. After a call to this method the service becomes no longer usable and should be discarded.
        Returns:
        remaining registered connections.