Exemple #1
0
	public void Pong(NetMsgs.Pong msg) {
		pongTimeout = Mathf.Max(pongTimeout, maxPongTimeout);
		
		var millis = Utils.ReadMilliseconds();
		var delta = millis - msg.time;
		pings[nextPing] = (int)delta;
		++nextPing;
		if (nextPing >= pings.Length) {
			nextPing = 0;
			pingFull = true;
		}

		if (pingFull) {
			ping = 0;

			for (int i = 0; i < pings.Length; ++i) {
				ping += pings[i];
			}

			if (ping < 0) {
				ping = 0;
			}

			ping /= pings.Length;
		}
	}
 void OnNetMsg(NetMsgs.Pong msg, ActorReplicationChannel channel)
 {
     channel.Pong(msg);
 }