Class Frame.Heartbeat
java.lang.Object
io.vertx.ext.stomp.Frame.Heartbeat
- Enclosing class:
Frame
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.- Author:
- Clement Escoffier
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.HeartbeatCreates an instance ofFrame.Heartbeatfrom theheartbeat headerof a frame .toString()
-
Constructor Details
-
Heartbeat
public Heartbeat(int x, int y)
-
-
Method Details
-
parse
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
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
-
computePingPeriod
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
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
-