public bool ReceiveResponse(BaseResponse response) { responseList.Add(response); BaseRequest request = FindRequest(response.CallBackId); if (request != null && request.HasResponse && request.CheckTimeout) { lastRequestTime = float.MaxValue; } if (request != null) { if (indicator == null) { indicator = (UiPnlTipIndicator)UiManager.Instance.ShowByName(UiPrefabNames.UiPnlTipIndicator); } if (indicator.IsShowing) { indicator.Hide(); } isWaitForRequest = false; SetUiCameraEvents(true); } return(true); }
public PLoginGS(LoginRes.AreaPro area, OnIsConnectedSuccess connectedSuccessDel, OnIsConnectedFailed connectedFailedDel) { this.area = area; this.gsHostName = area.InterfaceServerIp; this.gsHostPort = area.InterfaceServerPort; onIsConnectedSuccessDel = connectedSuccessDel; onIsConnectedFailedDel = connectedFailedDel; NeedResponse = false; // 由网络层给回调,拿不到响应,所以不需要响应 UiPnlTipIndicator.ShowIndicatorIfNot(); }
public bool SendRequest(BaseRequest request, bool checkLoseConnection = true) { Message message = request.GetMessage(); if (!request.NeedResponse) { if (message != null) { Business.SendMessage(message, 0, checkLoseConnection); } else { request.Execute(Business); } return(true); } else { if (indicator == null) { indicator = (UiPnlTipIndicator)UiManager.Instance.ShowByName(UiPrefabNames.UiPnlTipIndicator); } if (!indicator.IsShowing) { indicator.Show(); } isWaitForRequest = true; SetUiCameraEvents(false); } if (HasPreviousUnResponsedReq(request)) { return(false); } requestList.Add(request); lastAddRequestTime = Time.realtimeSinceStartup; if (request.HasResponse && request.CheckTimeout) { lastRequestTime = Time.realtimeSinceStartup; } return(true); }
/// <summary> /// 处理当发送消息时, 游戏服务器断开连接的情况 /// </summary> /// <param name="message"></param> /// <param name="reSendCount"></param> /// <param name="defaultResult"></param> /// <returns></returns> public bool ProcessOnLossGSConnectWhenSendMsg(ref Message message, int reSendCount, bool defaultResult) { PLoginGS loginGS = new PLoginGS(DataModelManager.Instance.AreaInfo, null, null); loginGS.Execute(this); bool isNeedQueryData = false; bool finished = false; int counter = 0; int sleepMS = 1; // 休息毫秒数 GCLoginGameMessage loginMsg = null; while ((!finished) && sleepMS * counter < 2000) { RequestManager.Instance.Business.Update(); finished = RequestManager.Instance.Business.OnLoginGSRes(out loginMsg, out isNeedQueryData); Thread.Sleep(sleepMS); counter++; } if (finished && loginMsg != null) { UiPnlTipIndicator.CloseIndicatorIfShowing(); switch (loginMsg.ResultCode) { case Protocols.GameLoginSuccess: { if (isNeedQueryData) { ReConnectManager.Instance.HandleReQueryData(); return(true); } else { if (message != null) { SendMessage(message, reSendCount + 1); return(true); } } } break; case Protocols.GameLoginSuccessRoleNotExist: case Protocols.GameLoginFail: case Protocols.GameLoginFromOthers: case Protocols.GameLoginFailNeedActiveCode: case Protocols.GameLoginTableVersionCheckSuccessUpdate: case Protocols.TableVersionCheckSuccessUpdate: default: { ReConnectManager.Instance.HandleGSClosed(); return(true); } } } else { ReConnectManager.Instance.HandleGSClosed(); return(false); } return(defaultResult); }