1. 程式人生 > >網狐框架分析二--登入伺服器

網狐框架分析二--登入伺服器

##1 登入伺服器 LogonServer啟動流程


```flow
st=>start: Start
io=>inputoutput: verification
op=>operation: Your Operation
cond=>condition: Yes or No?
e=>end


st->io->op->cond
cond(yes)->e
cond(no)->op
```
---
#2 流程分析
##LogonServerDlg(OnBnClickedStartService) //啟動


##=>m_LogonService.StartService()  //啟動服務

    ==>m_TimerEngine->StartService()     //時間引擎
        ===>m_TimerThread.StartThread() //啟動服務
        ===>CServiceThread::StartThread()//進入函式,開啟監聽執行緒_beginthreadex
            ====> CServiceThread::ThreadFunction()//執行緒函式
                =====>pServiceThread->OnEventThreadRun()//while迴圈中的函式


    ==>m_TCPSocketCorrespond->StartService()//網路引擎

        ===>CQueueService::StartService()//
            ====>CreateIoCompletionPort //建立完成埠
            ====> CServiceThread::StartThread()//啟動監聽執行緒_beginthreadex
                =====>pServiceThread->OnEventThreadRun()//一個while迴圈監聽函式

    ==>m_AttemperEngine->StartService()//排程引擎
        ===>m_QueueService.StartService()//啟動佇列

        ===>CQueueService::StartService()//建立完成埠,啟動執行緒
            ====>m_QueueServiceThread.StartThread()//
            ====>CServiceThread::StartThread()//_beginthreadex
                =====>CServiceThread::ThreadFunction()//
                    ======>pServiceThread->OnEventThreadRun()//while迴圈呼叫函式

    ==>m_DataBaseEngine->StartService()//資料引擎
        ===>CDataBaseEngine::StartService()//啟動服務
            ====>m_QueueServiceEvent.SetQueueServiceSink()//設定佇列
                =====>CQueueService::StartService()//建立完成埠,起執行緒
                    ======>m_QueueServiceThread.StartThread()//
                    ======> CServiceThread::StartThread()//_beginthreadex
                        =======>pServiceThread->OnEventThreadRun()//while迴圈呼叫函式
            ====>m_pIDataBaseEngineSink->OnDataBaseEngineStart()//啟動外掛
                =====>CDataBaseSink::OnDataBaseEngineStart()//模組啟動
                =====>m_AccountsDBModule->SetConnectionInfo()//連資料庫
                    ======>CDataBase::SetConnectionInfo()//設定構造連線字串
                =====>m_AccountsDBModule->OpenConnection()//發起連線
                    ======>CDataBase::OpenConnection()//發起連線
                        =======>m_DBConnection->Open()//_ConnectionPtr m_DBConnection;//資料庫物件

    ==>m_TCPNetworkEngine->StartService()//網路引擎
        ===>CTCPNetworkEngine::StartService()//
            //1.獲取cpu執行緒數
            //2.建立完成埠(啟動監聽執行緒while迴圈呼叫函式)
            //3.建立監聽SOCKET
            //4.啟動傳送佇列 m_SendQueueService.StartService();
            //5.建立讀寫執行緒,建立應答執行緒,執行讀寫執行緒,網路檢測執行緒,執行應答執行緒