コード例 #1
0
 public void TrySend(long currentTime, NetPeer peer)
 {
     if (_packet == null)
     {
         return;
     }
     if (_isSent) //check send time
     {
         double resendDelay    = peer.ResendDelay * TimeSpan.TicksPerMillisecond;
         double packetHoldTime = currentTime - _timeStamp;
         if (packetHoldTime < resendDelay)
         {
             return;
         }
         NetDebug.Write("[RC]Resend: {0} > {1}", (int)packetHoldTime, resendDelay);
     }
     _timeStamp = currentTime;
     _isSent    = true;
     peer.SendUserData(_packet);
 }
コード例 #2
0
            //Returns true if there is a pending packet inside
            public bool TrySend(DateTime currentTime, NetPeer peer)
            {
                if (_packet == null)
                {
                    return(false);
                }

                if (_isSent) //check send time
                {
                    TimeSpan resendDelay    = peer.ResendDelay;
                    TimeSpan packetHoldTime = currentTime - _timeStamp;
                    if (packetHoldTime < resendDelay)
                    {
                        return(true);
                    }

                    NetDebug.Write("[RC]Resend: {0} > {1}", packetHoldTime, resendDelay);
                }
                _timeStamp = currentTime;
                _isSent    = true;
                peer.SendUserData(_packet);
                return(true);
            }