Beispiel #1
0
 private IEnumerator ServerPinging(UdpSendUtils udpSendUtils)
 {
     while (!cts.IsCancellationRequested)
     {
         udpSendUtils.SendPingMessage();
         yield return(new WaitForSeconds(0.5f));
     }
 }
        public void TrySendPing()
        {
            DateTime now = DateTime.UtcNow;

            if (nextPingTime < now)
            {
                pingMessageSendingHistory.TryAdd(lastPingMessageId, now);
                udpSendUtils.SendPingMessage(lastPingMessageId);
                nextPingTime = now + TimeSpan.FromSeconds(0.5f);
                lastPingMessageId++;
            }
        }