public void OnTimerTick(long TickMs) { if (mNextState != eTesterState.NONE) { if (mCurState != mNextState) { mCurState = mNextState; } mNextState = eTesterState.NONE; } mCurDeltaTime += TickMs; SFConnection.Event conEvent; // Individual connection update loop if (m_ConnectionLogin != null) { var result = m_ConnectionLogin.DequeueEvent(out conEvent); while (result) { HandleLoginConnectionEvent(conEvent); if (m_ConnectionLogin == null) { return; } result = m_ConnectionLogin.DequeueEvent(out conEvent); } m_ConnectionLogin.UpdateMessageQueue(); } if (m_ConnectionGame != null) { var result = m_ConnectionGame.DequeueEvent(out conEvent); while (result) { HandleGameConnectionEvent(conEvent); if (m_ConnectionGame == null) { return; } result = m_ConnectionGame.DequeueEvent(out conEvent); } m_ConnectionGame.UpdateMessageQueue(); if (mCurState != eTesterState.NONE)// && m_ConnectionLogin.State != SFConnection.ConnectionState.DISCONNECTED) { if (m_Game != null && mCurDeltaTime >= 10000) { m_Game.HeartBitC2SEvt(); mCurDeltaTime = 0; } } } }
public void OnTimerTick(long TickMs) { if (mNextState != eTesterState.NONE) { if (mCurState != mNextState) { mCurState = mNextState; } mNextState = eTesterState.NONE; } SFConnection.Event conEvent; mHeartBitTime += TickMs; // Individual connection update loop if (m_ConnectionLogin != null) { var result = m_ConnectionLogin.DequeueEvent(out conEvent); while (result) { HandleLoginConnectionEvent(conEvent); if (m_ConnectionLogin == null) { return; } result = m_ConnectionLogin.DequeueEvent(out conEvent); } m_ConnectionLogin.UpdateMessageQueue(); } if (m_ConnectionGame != null) { var result = m_ConnectionGame.DequeueEvent(out conEvent); while (result) { HandleGameConnectionEvent(conEvent); if (m_ConnectionGame == null) { return; } result = m_ConnectionGame.DequeueEvent(out conEvent); } m_ConnectionGame.UpdateMessageQueue(); //if (mCurState != eTesterState.NONE && m_Game != null && m_ConnectionGame.State == SFConnection.ConnectionState.CONNECTED) //{ // if (mHeartBitTime >= 20) // { // this.m_Game.HeartBitC2SEvt(); // mHeartBitTime = 0; // } //} } }
public void OnTimerTick(long TickMs) { if (mNextState != eTesterState.NONE) { if (mCurState != mNextState) { mCurState = mNextState; } mNextState = eTesterState.NONE; } SFConnection.Event conEvent; // Individual connection update loop if (m_ConnectionLogin != null) { var result = m_ConnectionLogin.DequeueEvent(out conEvent); while (result) { HandleLoginConnectionEvent(conEvent); if (m_ConnectionLogin == null) { return; } result = m_ConnectionLogin.DequeueEvent(out conEvent); } m_ConnectionLogin.UpdateMessageQueue(); } if (m_ConnectionGame != null) { var result = m_ConnectionGame.DequeueEvent(out conEvent); while (result) { HandleGameConnectionEvent(conEvent); if (m_ConnectionGame == null) { return; } result = m_ConnectionGame.DequeueEvent(out conEvent); } m_ConnectionGame.UpdateMessageQueue(); } }
private void OnTimerTick(object sender, EventArgs e) { SFConnection.Event conEvent; // Individual connection update loop if (m_ConnectionLogin != null) { var result = m_ConnectionLogin.DequeueEvent(out conEvent); while (result) { HandleLoginConnectionEvent(conEvent); result = m_ConnectionLogin.DequeueEvent(out conEvent); } m_ConnectionLogin.UpdateMessageQueue(); } // Connection Group management if (m_ConnectionManagermentGroup != null) { SFConnectionGroup.EventInformation eventInfo; IntPtr connectionNativeHandle = m_ConnectionManagermentGroup.DequeueConnectionEvent(out eventInfo); if (connectionNativeHandle != null) { if (eventInfo.pMsg != null) { // You can separate message handling // 1. By having separate message router per connection m_MessageRouter.HandleRecvMessage(eventInfo.pMsg); } else if (m_ConnectionLogin != null && m_ConnectionLogin.NativeHandle == connectionNativeHandle) { HandleLoginConnectionEvent(eventInfo.Event); } eventInfo.Dispose(); } } }
void UpdateConnection() { if (m_ConnectionLogin == null) { return; } SFConnection.Event conEvent; var result = m_ConnectionLogin.DequeueEvent(out conEvent); while (result) { switch (conEvent.EventType) { case SFConnection.EventTypes.EVT_STATE_CHANGE: PrintStatus("Login Connection state chagned {0}", conEvent.State); break; case SFConnection.EventTypes.EVT_CONNECTION_RESULT: PrintStatus("Login Connection result {0}", conEvent.HResult); if (conEvent.HResult >= 0) { m_Login = new SF.Net.SendMessageLogin(m_ConnectionLogin); m_Login.CreateRandomUserCmd(m_GameID, m_LoginID); } break; case SFConnection.EventTypes.EVT_DISCONNECTED: PrintStatus("Login Connection disconnected"); if (m_ConnectionLogin != null) { m_ConnectionLogin.Dispose(); } m_ConnectionLogin = null; m_Login = null; break; } if (m_ConnectionLogin != null) { result = m_ConnectionLogin.DequeueEvent(out conEvent); } } if (m_ConnectionLogin != null) { m_ConnectionLogin.UpdateMessageQueue(); } }
private void OnTimerTick(object sender, EventArgs e) { SFConnection.Event conEvent; // Individual connection update loop if (m_ConnectionLogin != null) { var result = m_ConnectionLogin.DequeueEvent(out conEvent); while (result) { HandleLoginConnectionEvent(conEvent); result = m_ConnectionLogin.DequeueEvent(out conEvent); } m_ConnectionLogin.UpdateMessageQueue(); } if (m_ConnectionGame != null) { var result = m_ConnectionGame.DequeueEvent(out conEvent); while (result) { HandleGameConnectionEvent(conEvent); result = m_ConnectionGame.DequeueEvent(out conEvent); } m_ConnectionGame.UpdateMessageQueue(); if (m_ConnectionGame != null && m_ConnectionGame.State == SFConnection.ConnectionState.CONNECTED && (DateTime.Now - m_GameHeartBitTime).Seconds > 10) { m_GameHeartBitTime = DateTime.Now; if (m_Game != null) { m_Game.HeartbeatC2SEvt(); } } } // Connection Group management if (m_ConnectionManagermentGroup != null) { SFConnectionGroup.EventInformation eventInfo; IntPtr connectionNativeHandle = m_ConnectionManagermentGroup.DequeueConnectionEvent(out eventInfo); if (connectionNativeHandle != null) { if (eventInfo.pMsg != null) { // You can separate message handling // 1. By having separate message router per connection m_MessageRouter.HandleRecvMessage(eventInfo.pMsg); } else if (m_ConnectionLogin != null && m_ConnectionLogin.NativeHandle == connectionNativeHandle) { HandleLoginConnectionEvent(eventInfo.Event); } else if (m_ConnectionGame != null && m_ConnectionGame.NativeHandle == connectionNativeHandle) { HandleGameConnectionEvent(eventInfo.Event); } eventInfo.Dispose(); } } }