Example #1
0
 /// <summary>
 /// MeshAdapter层初始化函数
 /// </summary>
 public void Initialize()
 {
     m_Mesh.Initialize();
     m_Session.Initialize();
     m_dicOnLineWs.Clear();
     ReqBuffer.Reset();
     if (!preludeSystem(true))
     {
         CommStackLog.RecordErr(enLogLayer.eAdapter, "PreludeSystem failed in MeshAdapter.Initialize()!");
         throw new Exception("PreludeSystem failed in MeshAdapter.Initialize()!");
     }
 }
Example #2
0
        /// <summary>
        /// 会话失联后的动作
        /// </summary>
        private void sessnLost()
        {
            // 如果正在处理会话断开事件,则新到达的会话断开事件不予理会
            if (!m_bProcessingNewSessin)
            {
                // 如果系统运行至此,而且Session层状态为非失连状态(!SER_ST_DISCONNECTED),则来到此处是由于系统心跳线程检测到Manager失连
                // 此处应该主动将Session状态置为失连状态(SER_ST_DISCONNECTED)
                if (m_Session.Status != enSerStatus.SER_ST_DISCONNECTED)
                {
                    m_Session.Status = enSerStatus.SER_ST_DISCONNECTED;
                }

                m_bProcessingNewSessin = true;
                m_msigMainThreadRun.Reset();
                m_bPassiveNewSession = true;
                m_Mesh.ReleaseWaitResponse();

                // 重新建立会话时,清空请求列表
                ReqBuffer.Reset();
                // 重新建立会话时,清空等待应用层响应列表
                lock (m_dicWaitAppRespCmds)
                {
                    m_dicWaitAppRespCmds.Clear();
                }
                // 重新建立会话时,清空异步命令等待响应列表
                lock (m_Mesh.m_dicAsyncCmdRespRecords)
                {
                    m_Mesh.m_dicAsyncCmdRespRecords.Clear();
                }

                // 准备新的会话建立
                Thread CreateNewSessionThread = new Thread(createNewSessionWorker);
                CreateNewSessionThread.Priority = ThreadPriority.Highest;
                CreateNewSessionThread.Start();
            }
        }