/// <summary> /// 监听队伍发送改变就请求队伍位置 /// </summary> /// <param name="args"></param> public void UpdateRequsetTeam(CEventBaseArgs args) { if (IsEnable == false) { return; } if (mUpdateTeamPosCd != null) { return; } if (TeamManager.Instance.HaveTeam) { mUpdateTeamPosCd = new Utils.Timer(2000, true, 3000, (dt) => { if (!m_bNetAnswer) { ClearTeamPoint(); } m_bNetAnswer = false; var data = new C2STeamMemberPos(); NetClient.GetBaseClient().SendData <C2STeamMemberPos>(NetMsg.MSG_TEAM_MEMBER_POS, data); }); } }
public void ProcessLineCD(uint time) { SceneHelp.Instance.mChangeLineCDTime = time; mDelyLineCdTime = 0; ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_CHANGE_LINE_CD_TIME, new CEventBaseArgs()); uint cd = 0; cd = GameConstHelper.GetUint("GAME_LINE_CHANGE_CD"); if (SceneHelp.Instance.mChangeLineCDTime + cd > Game.GetInstance().ServerTime) { mDelyLineCdTime = SceneHelp.Instance.mChangeLineCDTime + cd - Game.GetInstance().ServerTime; mLineCDTimer = new Utils.Timer((int)mDelyLineCdTime * 1000, false, 1000, (dt) => { if (dt <= 0f) { mDelyLineCdTime = 0; ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_CHANGE_LINE_CD_TIME, new CEventBaseArgs()); if (mLineCDTimer != null) { mLineCDTimer.Destroy(); mLineCDTimer = null; } } else { mDelyLineCdTime = Mathf.Ceil(dt / 1000f); } }); } }
public void DestroyPoint() { mCurrentMonsterInfo = null; if (mUpdateTeamPosCd != null) { mUpdateTeamPosCd.Destroy(); mUpdateTeamPosCd = null; } UIResourceManager.Instance.DestroyPool(m_TranspotPoint); UIResourceManager.Instance.DestroyPool(m_TeamPoint); UIResourceManager.Instance.DestroyPool(m_MonsterPoint); UIResourceManager.Instance.DestroyPool(m_NpcPoint); }
/// <summary> /// 副连接心跳包更新 /// </summary> void OnCrossHeartTimeUpdate() { //GameDebug.Log("<<<MSG_ACC_HEART_MWAR:" + Time.unscaledTime); var cross_acc_heart = new C2SAccHeartMwar(); NetClient.GetCrossClient().SendData <C2SAccHeartMwar>(NetMsg.MSG_ACC_HEART_MWAR, cross_acc_heart); if (mCrossHeartTimeout != null) { mCrossHeartTimeout.Destroy(); mCrossHeartTimeout = null; } mCrossHeartTimeout = new Utils.Timer(GameConstHelper.GetInt("GAME_SYS_PING_TIMEOUT") * 1000, false, GameConstHelper.GetInt("GAME_SYS_PING_TIMEOUT") * 1000.0f, OnCrossHeartTimeout); }
/// <summary> /// 副连接网络断开 /// </summary> /// <param name="data"></param> void OnCrossNetDisconnect(CEventBaseArgs data) { if (m_Machine != null && Game.Instance.ForceDisconnect == false)// 网络断开分为链路断开和心跳包超时两种情况 { m_DisconnectReason = DisconnectReason.Corss; m_Machine.React((uint)EFSMEvent.DE_NetDisconnnect); } if (mCrossHeartTimeout != null) { mCrossHeartTimeout.Destroy(); mCrossHeartTimeout = null; } m_NextCrossHeartTime = float.MaxValue; }
/// <summary> /// 主连接心跳包超时 /// </summary> void OnHeartTimeout(float remainTime) { if (remainTime > 0) { return; } if (m_HeartTimeout != null) { m_HeartTimeout.Destroy(); m_HeartTimeout = null; } //如果Timeout时间内没有消息返回,则表示网络已断开 Game.GetInstance().OnNetDisconnect(NetType.NT_TCP, -2); }
/// <summary> /// 主连接心跳包的更新 /// </summary> void OnHeartTimeUpdate() { //GameDebug.Log("<<<MSG_ACC_HEART:"+Time.unscaledTime); mLastPingTime = UnityEngine.Time.realtimeSinceStartup; C2SAccHeart acc_heart = new C2SAccHeart(); NetClient.GetBaseClient().SendData <C2SAccHeart>(NetMsg.MSG_ACC_HEART, acc_heart); if (m_HeartTimeout != null) { m_HeartTimeout.Destroy(); m_HeartTimeout = null; } m_HeartTimeout = new Utils.Timer(GameConstHelper.GetInt("GAME_SYS_PING_TIMEOUT") * 1000, false, GameConstHelper.GetInt("GAME_SYS_PING_TIMEOUT") * 1000.0f, OnHeartTimeout); }
public override void DestroyBehaviour() { if (mUpdateTeamPosCd != null) { mUpdateTeamPosCd.Destroy(); mUpdateTeamPosCd = null; } if (mPlayOpenSysRoutine != null) { mPlayOpenSysRoutine.Stop(); mPlayOpenSysRoutine = null; } mNotEnterTipsTrigger.onPointerDown -= LostNotEnterTips; ClientEventMgr.Instance.UnsubscribeClientEvent((int)ClientEvent.CE_TEAM_INFO_CHANGED, TeamChange); base.DestroyBehaviour(); }
public void Reset() { if (mTimer != null) { mTimer.Destroy(); mTimer = null; } if (UICache != null) { UICache.Reset(); } mTimer = new Utils.Timer((int)(mRealDestroyWinTime * 1000), true, Mathf.Infinity, RealTimerRemove); IsBackMainMapShowWin = ""; }
/// <summary> /// 副连接心跳包超时 /// </summary> void OnCrossHeartTimeout(float remainTime) { if (remainTime > 0) { return; } if (mCrossHeartTimeout != null) { mCrossHeartTimeout.Destroy(); mCrossHeartTimeout = null; } //如果Timeout时间内没有消息返回,则表示网络已断开 //if (NetClient.CrossToggle) //CrossServerIntegration.GetInstance().Stop(); CrossServerIntegration.GetInstance().OnNetDisconnect(NetType.NT_TCP, -2); }
/// <summary> /// 主连接网络断开 /// </summary> /// <param name="data"></param> void OnMainNetDisconnect(CEventBaseArgs data) { if (Game.Instance.ForceDisconnect == false) { if (m_Machine != null) // 网络断开分为链路断开和心跳包超时两种情况 { m_DisconnectReason = DisconnectReason.Main; m_Machine.React((uint)EFSMEvent.DE_NetDisconnnect); } Game.Instance.Reset(true); } if (m_HeartTimeout != null) { m_HeartTimeout.Destroy(); m_HeartTimeout = null; } m_NextHeartTime = float.MaxValue; }
public ReportViewModel(IMvxLocationWatcher watcher) { // Message subs. var messenger = Mvx.Resolve <IMvxMessenger>(); _token = messenger.Subscribe <LocationMessage>(OnLocationMessage); // Location service. Mvx.RegisterSingleton <ILocationService>(new LocationService(watcher, messenger)); // Compass. CrossCompass.Current.CompassChanged += (s, e) => { Heading = e.Heading; }; CrossCompass.Current.Start(); _timer = new Utils.Timer(async(obj) => { await CheckDanger().ConfigureAwait(false); }, null, 15000, 15000); }
public override void EnableBehaviour(bool isEnable) { m_lastUnlockMapId = 0; mOpenRoot.SetActive(false); mEffectUnLock.SetActive(false); base.EnableBehaviour(isEnable); if (isEnable) { if (mUpdateTeamPosCd != null) { mUpdateTeamPosCd.Destroy(); mUpdateTeamPosCd = null; } mNotEnterTipsTrigger.gameObject.SetActive(false); mNotEnterTips.SetActive(false); UpdatePlayerPos(); TeamChange(null); //SetMapIconState(true); if (mPlayOpenSysRoutine != null) { mPlayOpenSysRoutine.Stop(); mPlayOpenSysRoutine = null; } //CheckOpenInstance(); } else { if (mPlayOpenSysRoutine != null) { mPlayOpenSysRoutine.Stop(); mPlayOpenSysRoutine = null; } } }
public void ClearPoint() { mCurrentMonsterInfo = null; if (mUpdateTeamPosCd != null) { mUpdateTeamPosCd.Destroy(); mUpdateTeamPosCd = null; } ClearTeamPoint(); if (mMonsterListPointObjs.Count > 0) { foreach (var kv in mMonsterListPointObjs) { UIResourceManager.Instance.ReturnObjectToPool(kv.Value); } mMonsterListPointObjs.Clear(); } if (mTranspotListPointObjs.Count > 0) { for (int i = 0; i < mTranspotListPointObjs.Count; i++) { UIResourceManager.Instance.ReturnObjectToPool(mTranspotListPointObjs[i]); } mTranspotListPointObjs.Clear(); } if (mNpcListPointObjs.Count > 0) { foreach (var kv in mNpcListPointObjs) { UIResourceManager.Instance.ReturnObjectToPool(kv.Value); } mNpcListPointObjs.Clear(); } }
//----------------------------------- // 网络消息 //----------------------------------- void HandleServerData(ushort protocol, byte[] data) { switch (protocol) { case NetMsg.MSG_ACC_SESSION: // 接收主连接Token { GameDebug.Log(">>>MSG_ACC_SESSION"); var session = S2CPackBase.DeserializePack <S2CAccSession>(data); GlobalConfig.Instance.Token = session.token; break; } case NetMsg.MSG_ACC_SESSION_LOGIN: // 接收主连接Token登录的结果 { GameDebug.Log(">>>MSG_ACC_SESSION_LOGIN"); var session_login = S2CPackBase.DeserializePack <S2CAccSessionLogin>(data); if (session_login.result == 0) { GameDebug.Log("主连接重连失败"); m_ForceRebot = true; m_Machine.React((uint)EFSMEvent.DE_ReconnectFail); } else { GameDebug.Log("主连接重连成功"); } break; } case NetMsg.MSG_MWAR_TOKEN: // 收到副连接的Token信息就开始Connect { GameDebug.Log(">>>MSG_MWAR_TOKEN"); if (NetClient.CrossToggle) { CrossServerIntegration.GetInstance().Stop(); } S2CMwarToken rep = S2CPackBase.DeserializePack <S2CMwarToken>(data); m_IsRecvToken = true; m_CrossToken = rep.token; if (Game.Instance.Connected) // 主连接连上了再连接副连接 { ConnectCrossServer(rep.ip, (int)rep.port, rep.token); } else { m_WaitConnect = MainGame.HeartBehavior.StartCoroutine(WaitConnectCrossServer(rep.ip, (int)rep.port, rep.token)); } break; } case NetMsg.MSG_MWAR_LOGIN: // 副连接登录成功 { GameDebug.Log(">>>MSG_MWAR_LOGIN"); var mwar_login = S2CPackBase.DeserializePack <S2CMwarLogin>(data); if (mwar_login.result == 0) { if (m_Machine != null) // 副连接连上了才表示网络连接成功 { UINotice.Instance.ShowMessage(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_87")); m_Machine.React((uint)EFSMEvent.DE_ReconnectFail); } } else if (mwar_login.result == 1) { ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_NET_CROSS_CONNECTED, null); } break; } case NetMsg.MSG_ACC_HEART: // 主连接心跳包 { //Debug.Log(">>>MSG_ACC_HEART"); // 服务器有返回消息,则将计时器销毁 if (m_HeartTimeout != null) { m_HeartTimeout.Destroy(); m_HeartTimeout = null; } var dt = UnityEngine.Time.realtimeSinceStartup - mLastPingTime; PingTime.GetInstance().DelayTime = dt; } break; case NetMsg.MSG_ACC_HEART_MWAR: // 副连接心跳包 { //Debug.Log(">>>MSG_ACC_HEART_MWAR"); // 服务器有返回消息,则将计时器销毁 if (mCrossHeartTimeout != null) { mCrossHeartTimeout.Destroy(); mCrossHeartTimeout = null; } } break; } }
private Timer AddIfNotExists(string name) { if (!this.Timers.ContainsKey(name)) { var t = new Timer { totalTimeMS = 0.0, count = 0, sw = new Stopwatch() }; this.Timers.Add(name, t); return t; } return this.Timers[name]; }