io.vertx.ext.stomp

## Class Frame.Heartbeat

- java.lang.Object
- - io.vertx.ext.stomp.Frame.Heartbeat

- Enclosing class:
    Frame

      public static class Frame.Heartbeat
      extends 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 Summary

    Constructors
    Constructor and Description
    `Heartbeat(int x, int y)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static long` | `computePingPeriod(Frame.Heartbeat client, Frame.Heartbeat server)` Computes the ping period.
    `static long` | `computePongPeriod(Frame.Heartbeat client, Frame.Heartbeat server)` Computes the pong period.
    `static Frame.Heartbeat` | `create(JsonObject json)` Creates an instance of `Frame.Heartbeat` from the JSON configuration provides in the client / server options.
    `static Frame.Heartbeat` | `parse(String header)` Creates an instance of `Frame.Heartbeat` from the `heartbeat header` of a frame .
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Heartbeat

          public Heartbeat(int x,
                           int y)

  - ### Method Detail

    - #### parse

          public static Frame.Heartbeat parse(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(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 String toString()

      Overrides:
        `toString` in class `Object`
      Returns:
        the heartbeat configuration to be used in the `heartbeat` header.

    - #### computePingPeriod

          public static long computePingPeriod(Frame.Heartbeat client,
                                               Frame.Heartbeat server)

      Computes the ping period. The party must send a `ping` to the other party every x milliseconds, where x is the value returned by this method. The value is computed from the two parties heartbeat configuration.
      Parameters:
        `client` - the client configuration
        `server` - the server configuration
      Returns:
        the ping period

    - #### computePongPeriod

          public static long computePongPeriod(Frame.Heartbeat client,
                                               Frame.Heartbeat server)

      Computes the pong period. The party can consider the other party inactive when it did not receives any message since x, where x is the value returned by this method. The value is computed from the two parties heartbeat configuration.
      Parameters:
        `client` - the client configuration
        `server` - the server configuration
      Returns:
        the pong period

Copyright © 2021 Eclipse. All rights reserved.