Skip to main content

PingMessage

A static class in Root.Township, Alta.Networking.

The ping network message. The client sends a timestamp, the server echoes it back, and the client works out the round trip time.

Fields​

3 private and internal fields
MemberWhat it is
private static uint idBacking field for Id (sent in 8 bits).
private static bool isResponseSet to false by Set; not otherwise used.
private static uint timeBacking field for Time.

Properties​

MemberWhat it is
static uint Id { get; }The id of the last ping set or received.
static float LastPingInSeconds { get; private set; }Client: round trip time of the last answered ping, in seconds.
static uint Time { get; }The timestamp of the last ping set or received.

Methods​

MemberWhat it is
static void Serialize(Connection connection, Stream stream)Writes or reads the id and time. On read the server replies with the same data; the client updates LastPingInSeconds.
static void Set(uint sendId = 0)Fills the message with an id and the current time (low 32 bits of UTC ticks).
static void SetElapsedTicks()Sets LastPingInSeconds from the time since the received timestamp.