Class HeartbeatMessage
- Namespace
- SteamNetworkLib.Models
- Assembly
- SteamNetworkLib.dll
Represents a heartbeat message for connection monitoring, latency measurement, and keepalive functionality. Used to monitor P2P network performance.
public class HeartbeatMessage : P2PMessage
- Inheritance
-
HeartbeatMessage
- Inherited Members
Constructors
HeartbeatMessage()
public HeartbeatMessage()
Properties
AverageLatencyMs
Gets or sets the average latency in milliseconds. Calculated from recent ping/pong round-trip times.
public float AverageLatencyMs { get; set; }
Property Value
BandwidthUsage
Gets or sets the current bandwidth usage in bytes per second. Includes both incoming and outgoing data transfer rates.
public int BandwidthUsage { get; set; }
Property Value
ConnectionInfo
Gets or sets additional metadata about the player's connection. Can include information like connection type, NAT status, or other network details.
public string ConnectionInfo { get; set; }
Property Value
HeartbeatId
Gets or sets the unique identifier for this heartbeat. Used for matching ping and pong messages to calculate round-trip time.
public string HeartbeatId { get; set; }
Property Value
HighPrecisionTimestamp
Gets or sets the high-precision timestamp when this heartbeat was sent. Used for accurate latency calculations using system ticks or similar high-resolution timing.
public long HighPrecisionTimestamp { get; set; }
Property Value
IsResponse
Gets or sets a value indicating whether this is a response to a heartbeat (pong). When false, this is an initial heartbeat (ping). When true, this is a response (pong).
public bool IsResponse { get; set; }
Property Value
MessageType
Gets the message type identifier for heartbeat messages.
public override string MessageType { get; }
Property Value
PacketLossPercent
Gets or sets the connection quality information as packet loss percentage. Value between 0.0 and 100.0 indicating the percentage of packets lost.
public float PacketLossPercent { get; set; }
Property Value
PlayerStatus
Gets or sets the current player status or state. Common values include "online", "away", "busy", "playing", etc.
public string PlayerStatus { get; set; }
Property Value
SequenceNumber
Gets or sets the sequence number for tracking heartbeat order. Helps detect lost heartbeats and measure packet ordering.
public uint SequenceNumber { get; set; }
Property Value
Methods
Deserialize(byte[])
Deserializes the heartbeat message from a byte array received over the network.
public override void Deserialize(byte[] data)
Parameters
data
byte[]The byte array containing the serialized message data.
Serialize()
Serializes the heartbeat message to a byte array for network transmission.
public override byte[] Serialize()
Returns
- byte[]
A byte array containing the serialized message data in JSON format.