Table of Contents

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

float

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

int

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

string

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

string

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

long

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

bool

MessageType

Gets the message type identifier for heartbeat messages.

public override string MessageType { get; }

Property Value

string

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

float

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

string

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

uint

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.