Used to measure the ping time, which reports how fast messages can be bounced between the two network cards.
The object spawns
a separate high-priority thread for just bouncing ping messages between the network cards.
The ping times reported by Network.ping() take into account the full roundtrip time of network messages. That means they also
include the latency arising from the fact that network messages are only processed at a specific point in the frame, not at the
instance they arrive to the network card. This introduces a latency of half a frame time when the ping message is ponged, and half
a frame time again when it is received, so in total on average one extra frame of latency (or 33 ms at 30 fps). This would be the
most accurate ping time, because it tells you how fast the server will be able to react to your actions and drives the player experience.
The ping time reported by SteamPingThread is a smaller number than the actual ping time, and does directly relate to the player experience.
You must call stingray.SteamPingThread.destroy() on the ping thread to destroy it when you are done with it to free the thread.
This must be done before shutting down the network.
Note: This interface should be considered experimental. Its API may change in future versions.
|
Adds the specified peer to the list of peers that the ping server should keep track of.
|
Parameters self : | stingray.SteamPingThread | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
peer_id : | string | The ID of the peer to ping. |
Returns | This function does not return any values. |
The thread will send ping
messages to the added peers every 2 seconds and measure their response times.
Note that the peers you add must also be running a SteamPingThread, otherwise they will not respond to the ping messages
and you will not be able to measure ping times. However, the remote peers do not need to add you back as a peer in their own
ping threads.
|
Destroys the specified ping thread: frees all memory used by it, and stops the thread.
|
Parameters self : | stingray.SteamPingThread | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
Returns | This function does not return any values. |
After calling this function, no other functions of the SteamPingThread interface can be called on the
specified ping thread.
|
ping ( self, peer_id ) : number
Returns the ping time to the specified peer.
|
Parameters self : | stingray.SteamPingThread | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
peer_id : | string | The ID of the peer whose ping time you want to retrieve. |
Returns number |
The ping time in seconds, or 0 if the ping thread has not been able to measure
ping times due to the connection to the remote peer being broken or the peer not
running a SteamPingThread.
|
|
Removes a peer that was previously added with add_peer(), and stops tracking ping times to that peer.
|
Parameters self : | stingray.SteamPingThread | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
peer_id : | string | The ID of the peer to remove. |
Returns | This function does not return any values. |