示例#1
0
        void HandleLoginConnectionEvent(SFConnection.Event conEvent)
        {
            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.IsSucceeded)
                {
                    m_Login = new SF.Net.SendMessageLogin(m_ConnectionLogin);
                    m_Login.CreateRandomUserCmd(0, StringCrc32.HashString(m_GameID), m_LoginID);

                    if (mLoginConnectedAction != null)
                    {
                        mLoginConnectedAction(this);
                    }
                }
                break;

            case SFConnection.EventTypes.EVT_DISCONNECTED:
            {
                PrintStatus("Login Connection disconnected");
                if (mLoginDisConnectedAction != null)
                {
                    mLoginDisConnectedAction(this, m_Login);
                }
            }
            break;
            }
        }
示例#2
0
        void Connect(NetAddress serverAddress)
        {
            CloseAllConnections();

            m_ConnectionLogin = new SFConnection(m_MessageRouter);
            m_ConnectionLogin.Connect(0, serverAddress.Address, (int)serverAddress.Port);
            m_Login = new SF.Net.SendMessageLogin(m_ConnectionLogin);
        }
        public void CloseAllConnections()
        {
            if (m_ConnectionGame != null)
            {
                if (m_ConnectionGame.State != SFConnection.ConnectionState.DISCONNECTED)
                {
                    if (mGameSvrDisConnectedAction != null)
                    {
                        mGameSvrDisConnectedAction(this, m_Game);
                    }
                }
            }

            if (m_ConnectionLogin != null)
            {
                if (m_ConnectionLogin.State != SFConnection.ConnectionState.DISCONNECTED)
                {
                    if (mLoginDisConnectedAction != null)
                    {
                        mLoginDisConnectedAction(this, m_Login);
                    }
                }
            }

            if (m_Login != null)
            {
                m_Login = null;
            }

            if (m_Game != null)
            {
                m_Game = null;
            }

            if (m_ConnectionLogin != null)
            {
                m_ConnectionLogin.Disconnect();
                m_ConnectionLogin.Dispose();
            }
            m_ConnectionLogin = null;

            if (m_ConnectionGame != null)
            {
                m_ConnectionGame.Disconnect();
                m_ConnectionGame.Dispose();
            }
            m_ConnectionGame = null;

            if (m_PartyInfo != null)
            {
                m_PartyInfo.Dispose();
            }

            m_PartyInfo = null;

            mRecvChatHistorys.Clear();
        }
示例#4
0
        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();
            }
        }
示例#5
0
        public void CloseAllConnections()
        {
            if (m_ConnectionGame != null)
            {
                if (m_ConnectionGame.State != SFConnection.ConnectionState.DISCONNECTED)
                {
                    if (mGameSvrDisConnectedAction != null)
                    {
                        mGameSvrDisConnectedAction(this, m_Game);
                    }
                }
            }

            if (m_ConnectionLogin != null)
            {
                if (m_ConnectionLogin.State != SFConnection.ConnectionState.DISCONNECTED)
                {
                    if (mLoginDisConnectedAction != null)
                    {
                        mLoginDisConnectedAction(this, m_Login);
                    }
                }
            }

            m_Login = null;
            m_Game  = null;

            if (m_ConnectionLogin != null)
            {
                m_ConnectionLogin.Dispose();
            }

            m_ConnectionLogin = null;

            if (m_ConnectionGame != null)
            {
                m_ConnectionGame.Dispose();
            }
            m_ConnectionGame = null;

            if (m_MatchedInfo != null)
            {
                m_MatchedInfo.Dispose();
            }

            //   PrintStatus("m_MatchedInfo Delete ID = {0}", m_LoginID);
            m_MatchedInfo = null;
        }
示例#6
0
        void HandleLoginConnectionEvent(SFConnection.Event conEvent)
        {
            switch (conEvent.EventType)
            {
            case SFConnection.EventTypes.EVT_STATE_CHANGE:
                //PrintStatus("Login Connection state chagned {0} ID = {1}", conEvent.State, m_LoginID);
                break;

            case SFConnection.EventTypes.EVT_CONNECTION_RESULT:

                PrintStatus(1, "Login Connection result CID:{0}, hr:{1} ID = {2}", m_ConnectionLogin.CID, conEvent.HResult, m_LoginID);
                if (conEvent.HResult.IsSucceeded)
                {
                    if (mLoginConnectedAction != null)
                    {
                        mLoginConnectedAction(this);
                    }

                    m_Login = new SF.Net.SendMessageLogin(m_ConnectionLogin);
                    m_Login.CreateRandomUserCmd(0, StringCrc32.HashString(m_GameID), m_LoginID);
                }
                else
                {
                    if (mLoginFailedConnectAction != null)
                    {
                        mLoginFailedConnectAction(this);
                    }
                }
                break;

            case SFConnection.EventTypes.EVT_DISCONNECTED:
            {
                if (mLoginDisConnectedAction != null)
                {
                    mLoginDisConnectedAction(this, m_Login);
                }

                PrintStatus(0, "Login Connection disconnected ID = {0}", m_LoginID);
            }
            break;
            }
        }
示例#7
0
        public void CloseAllConnections()
        {
            if (m_ConnectionLogin != null)
            {
                if (m_ConnectionLogin.State != SFConnection.ConnectionState.DISCONNECTED)
                {
                    if (mLoginDisConnectedAction != null)
                    {
                        mLoginDisConnectedAction(this, m_Login);
                    }
                }
            }

            if (m_ConnectionLogin != null)
            {
                m_ConnectionLogin.Dispose();
            }
            m_ConnectionLogin = null;

            m_Login = null;
        }