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 theheartbeat
header. 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 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 ofFrame.Heartbeat
from the JSON configuration provides in the client / server options.static Frame.Heartbeat
parse(String header)
Creates an instance ofFrame.Heartbeat
from theheartbeat header
of a frame .String
toString()
-
-
-
Method Detail
-
parse
public static Frame.Heartbeat parse(String header)
Creates an instance ofFrame.Heartbeat
from theheartbeat header
of 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.Heartbeat
from the JSON configuration provides in the client / server options. The JSON is structure as follows:{"x": 1000, "y": 1000}
. Thex
andy
time 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 aping
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 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
-
-