Package 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 theheartbeatheader. This class is thread-safe.
-
-
Constructor Summary
Constructors Constructor Description Heartbeat(int x, int y)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longcomputePingPeriod(Frame.Heartbeat client, Frame.Heartbeat server)Computes the ping period.static longcomputePongPeriod(Frame.Heartbeat client, Frame.Heartbeat server)Computes the pong period.static Frame.Heartbeatcreate(JsonObject json)Creates an instance ofFrame.Heartbeatfrom the JSON configuration provides in the client / server options.static Frame.Heartbeatparse(String header)Creates an instance ofFrame.Heartbeatfrom theheartbeat headerof a frame .StringtoString()
-
-
-
Method Detail
-
parse
public static Frame.Heartbeat parse(String header)
Creates an instance ofFrame.Heartbeatfrom theheartbeat headerof a frame . If the header isnull, 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 ofFrame.Heartbeatfrom the JSON configuration provides in the client / server options. The JSON is structure as follows:{"x": 1000, "y": 1000}. Thexandytime are given in milliseconds.- Parameters:
json- the json object configuring the heartbeat.- Returns:
- the heartbeat configuration
-
toString
public String toString()
-
computePingPeriod
public static long computePingPeriod(Frame.Heartbeat client, Frame.Heartbeat server)
Computes the ping period. The party must send apingto 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 configurationserver- 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 configurationserver- the server configuration- Returns:
- the pong period
-
-