Class Frame.Heartbeat

  • Enclosing class:
    Frame

    public static class Frame.Heartbeat
    extends java.lang.Object
    Represents the heartbeat configuration. Heartbeat determine when a party involved in the exchange (either the client or the server) can detect the inactivity of the other party and close the connection. Configuration is made in the heartbeat header. This class is thread-safe.
    • Constructor Detail

      • Heartbeat

        public Heartbeat​(int x,
                         int y)
    • Method Detail

      • parse

        public static Frame.Heartbeat parse​(java.lang.String header)
        Creates an instance of Frame.Heartbeat from the heartbeat header of a frame . If the header is null, the (0,0) configuration is returned.
        Parameters:
        header - the header
        Returns:
        the heartbeat configuration
      • create

        public static Frame.Heartbeat create​(io.vertx.core.json.JsonObject json)
        Creates an instance of Frame.Heartbeat from the JSON configuration provides in the client / server options. The JSON is structure as follows: {"x": 1000, "y": 1000}. The x and y time are given in milliseconds.
        Parameters:
        json - the json object configuring the heartbeat.
        Returns:
        the heartbeat configuration
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        the heartbeat configuration to be used in the heartbeat header.
      • computeClientHeartbeatPeriod

        public static long computeClientHeartbeatPeriod​(Frame.Heartbeat client,
                                                        Frame.Heartbeat server)
        Computes the period at which the client must send a Heartbeat to the server. If no heartbeat or other data is received within this time the client must be considered inactive. The value is computed from the two parties heartbeat configuration.
        Parameters:
        client - the client configuration
        server - the server configuration
        Returns:
        the clientHeartbeat period
      • computeServerHeartbeatPeriod

        public static long computeServerHeartbeatPeriod​(Frame.Heartbeat client,
                                                        Frame.Heartbeat server)
        Computes the period at which the server must send a Heartbeat to the client. If no heartbeat or other data is received within this time the server must be considered inactive. The value is computed from the two parties heartbeat configuration.
        Parameters:
        client - the client configuration
        server - the server configuration
        Returns:
        the serverHeartbeat period