peng3dnet.ext.ping - One-off data retrieval protocol extension¶
The ping extension was designed to allow a client to check on various values the server provides without much effort. It allows the client to check on metrics such as latency and additional values able to be customized by the server.
This extension is named after the UNIX ping utility, though it can do much more than just check on availability and latency.
-
class
peng3dnet.ext.ping.PingConnectionType(peer)[source]¶ Connection type to be used by ping connections.
This connection type prevents any synchronization of the registry to allow clients only supporting a subset of the peng3dnet protocol to still ping a server.
Additonally, conventional processing of packets will be disabled by this connection type, making it uneccessary to register packets with the client or server.
-
getPingData(msg, cid=None)[source]¶ Overridable method to create a ping response.
msgis the ping query, as received from the client.cidis the ID of the client.Called only on the server side.
-
init(cid)[source]¶ Called whenever a new ping connection is established.
On the client, this calls
PingableClientMixin._ping()and updates the connection state, while on the server only the connection state is updated.
-
-
class
peng3dnet.ext.ping.PingableClientMixin[source]¶ Mixin for
Clientclasses enabling support for pinging the server.Currently automatically adds the
pingconnection type.
-
class
peng3dnet.ext.ping.PingableServerMixin[source]¶ Mixin for
Serverclasses enabling support for pinging the server.Currently automatically adds the
pingconnection type.-
getPingData(msg, cid)[source]¶ Overrideable method called to extend the default dictionary returned upon a ping request.
May be overriden to add dynamic data like user count or similiar information.
msgis the original message as received from the client.cidis the client ID that made this request.
-
pingdata= {}¶ Overrideable dictionary used to extend the default dictionary returned upon a ping request.
May be overriden to add static data like server name or similiar information.
-
-
peng3dnet.ext.ping.WRITEBACK= True¶ Constant allowing to configure if the received ping message should be transmitted back to the client.
If there should ever be any security concerns regarding that feature, this flag can simply be flipped.
-
peng3dnet.ext.ping.pingServer(peng=None, addr=None, cfg=None, data=None, clientcls=<class 'peng3dnet.ext.ping._PingClient'>, timeout=10.0)[source]¶ Pings the specified server.
Internally, this creates a client that supports pinging and listens for any data received back.
pengmay be optionally used to replace the argument of the same name toClient().addrspecifies the address of the server to ping.cfgmay be used to override the configuration for the client, e.g. SSL settings.datais the data sent to the server. Note that thetimekey will be overridden for measuring the latency.clientclsmay be used to override the client class used.timeoutis maximum amount of time to wait for a response.The data returned will be the data received from the server, except for additional information that has been added. Currently, the
recvtimekey contains the timestamp that the response was received and thedelaykey contains the total roundtrip time in seconds.