Exemple #1
0
    public void Close()
    {
        m_bIsRunning = false;

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

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

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

        if (m_aThreadMain != null)
        {
            m_aThreadMain.Interrupt();
            m_aThreadMain = null;
        }

        DelAllSession();
    }
Exemple #2
0
    public bool Start(int port)
    {
        if (m_bIsRunning)
        {
            return(false);
        }

        DelAllSession();
        try
        {
            m_nLogicLastTicks  = DateTime.Now.Ticks;
            m_RealTicksAtStart = m_nLogicLastTicks;

            m_aGameSocket = new KCPSocket(0, 1);
            m_aGameSocket.AddReceiveListener(OnReceive);
            m_bIsRunning = true;

            m_aRoom = new FSPRoom();
            m_aRoom.Create();

            m_aThreadMain = new Thread(Thread_Main)
            {
                IsBackground = true
            };
            m_aThreadMain.Start();
        }
        catch (Exception e)
        {
            Close();
            return(false);
        }

        return(true);
    }