///////////////////////////////// PONG ////////////////////////////////// private void HandlePong(bool send, DecodeRspResult res, DateTime startTime) { PongTimer.Stop(); Debugger.Log("Pong {0} {1} {2}", this.Id, res.RspWrap1.Seq, send); if (!send) { this.HandlePongTimeout(res.RspWrap1.Seq); return; } this.Retry = MaxPingRetry; // 清空发送队列 this.client.ClearQueue(); // 心跳的错误码单独处理 var errCode = res.RspWrap1.ErrCode; // 上报心跳时延 if (this.Id == 1 && errCode == ErrCode.EcOk) { EventUpload.PushPingEvent(new PingEventParam(Convert.ToInt64((DateTime.Now - startTime).TotalMilliseconds))); } if (IsTokenError(errCode)) { UserStatus.SetStatus(UserStatus.StatusType.Logout); this.client.Socket.Emit("autoAuth", new SocketEvent()); return; } if (IsRelayConnectError(errCode) && this.client.Socket.Id == (int)ConnectionType.Relay) { CheckLoginStatus.SetStatus(CheckLoginStatus.StatusType.Offline); this.client.Socket.Emit("autoAuth", new SocketEvent()); return; } this.PingTimer.SetTimer(() => this.Ping(null), this.Timeout); }
public void Stop() { PingTimer.Close(); PongTimer.Close(); }