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); }
//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); }