예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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();
                }
            }
        }