private void SetCurPkgPing(int seqNo) { long ticks = DateTime.Now.Ticks; SendPkgData sendPkgData = this.sendArr[seqNo % 1000]; if (sendPkgData != null) { long delayTime = ticks - sendPkgData.firstTimeTick; PingStatisticInfo pingStatisticInfo = this.pingInfo[this.curPingIdx % 9]; pingStatisticInfo.tick = ticks; pingStatisticInfo.delayTime = delayTime; this.curPingIdx++; } }
public void UpdatePing() { SendPkgData sendPkgData = this.sendArr[this.firstSeqNo % 1000]; if (sendPkgData != null) { long num = DateTime.Now.Ticks - sendPkgData.firstTimeTick; if (num > this.channel.ping) { PingStatisticInfo pingStatisticInfo = this.pingInfo[9]; pingStatisticInfo.delayTime = num; } } }
private SendPkgData AllocPkgData() { SendPkgData result; while (this.dataPool.Count > 0) { SendPkgData sendPkgData = this.dataPool[0]; this.dataPool.RemoveAt(0); if (sendPkgData != null) { result = sendPkgData; return(result); } } result = new SendPkgData(); return(result); }
public SendPkgData GetFirstPkgWaitingAck() { SendPkgData result; for (int i = this.firstSeqNo; i < this.nextSeqNo; i++) { int num = i % 1000; SendPkgData sendPkgData = this.sendArr[num]; if (sendPkgData != null) { result = sendPkgData; return(result); } } result = null; return(result); }
private void appendToCache(PvpCode code, int seqNo, Dictionary <byte, object> param) { SendPkgData sendPkgData = this.AllocPkgData(); sendPkgData.code = code; sendPkgData.SaveRsp(param); sendPkgData.timeTick = DateTime.Now.Ticks; sendPkgData.firstTimeTick = sendPkgData.timeTick; this.sendArr[seqNo % 1000] = sendPkgData; if (this.nextSeqNo == seqNo) { this.nextSeqNo++; if (this.nextSeqNo < 0) { this.nextSeqNo = 0; } } }
public void RetrySendCachePkg() { for (int i = this.firstSeqNo; i < this.nextSeqNo; i++) { int num = i % 1000; SendPkgData sendPkgData = this.sendArr[num]; if (sendPkgData != null) { int resendInterval = this.GetResendInterval(sendPkgData.resendCnt); long num2 = DateTime.Now.Ticks - sendPkgData.timeTick; if (num2 >= (long)resendInterval) { sendPkgData.ResetSendTick(); sendPkgData.rsp[3] = sendPkgData.resendCnt; this.channel.Send(sendPkgData.code, sendPkgData.rsp, true); } } } }
public void OnUpdate() { SendPkgData firstPkgWaitingAck = this.sendPkgMgr.GetFirstPkgWaitingAck(); if (firstPkgWaitingAck != null && DateTime.Now.Ticks - firstPkgWaitingAck.firstTimeTick > 100000000L) { this.pvpPeer.Disconnect(); } else { this.sendPkgMgr.UpdatePing(); this.sendPkgMgr.RetrySendCachePkg(); if (this.waitingSendPkg != null && this.sendPkgMgr.GetNumberOfWaitingAck() <= 0) { this.Send(this.waitingSendCode, this.waitingSendPkg, false); this.waitingSendPkg = null; } } }
private void ReleasePkgData(SendPkgData data) { data.resendCnt = 0; data.timeTick = 0L; this.dataPool.Add(data); }