Package io.vertx.ext.stomp.lite.frame
Class Frame.Heartbeat
- java.lang.Object
-
- io.vertx.ext.stomp.lite.frame.Frame.Heartbeat
-
- Enclosing class:
- Frame
public static class Frame.Heartbeat extends java.lang.ObjectRepresents 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 longcomputeClientHeartbeatPeriod(Frame.Heartbeat client, Frame.Heartbeat server)Computes the period at which the client must send a Heartbeat to the server.static longcomputeServerHeartbeatPeriod(Frame.Heartbeat client, Frame.Heartbeat server)Computes the period at which the server must send a Heartbeat to the client.static Frame.Heartbeatcreate(io.vertx.core.json.JsonObject json)Creates an instance ofFrame.Heartbeatfrom the JSON configuration provides in the client / server options.static Frame.Heartbeatparse(java.lang.String header)Creates an instance ofFrame.Heartbeatfrom theheartbeat headerof a frame .java.lang.StringtoString()
-
-
-
Method Detail
-
parse
public static Frame.Heartbeat parse(java.lang.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(io.vertx.core.json.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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- the heartbeat configuration to be used in the
heartbeatheader.
-
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 configurationserver- 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 configurationserver- the server configuration- Returns:
- the serverHeartbeat period
-
-