예제 #1
0
        /// <summary>
        /// 服务器 Session 事件(session_open、session_close)
        /// </summary>
        void Server_OnEvent(IntPtr session, int eventCode, ref BVCU_Event_Common eventCommon)
        {
            switch (eventCode)
            {
            case BVCU.BVCU_EVENT_SESSION_OPEN:    //建立连接事件
                if (eventCommon.errorCode == BVCU.BVCU_RESULT_S_OK)
                {
                    m_session.OnLoginOk();    //连接成功, 更新设备列表...
                    return;
                }
                else if (eventCommon.errorCode == BVCU.BVCU_RESULT_E.TIMEOUT)
                {
                    Console.WriteLine("连接服务器超时");
                }
                else if (eventCommon.errorCode == BVCU.BVCU_RESULT_E.CONNECTFAILED)
                {
                    Console.WriteLine("连接服务器失败");
                }
                m_session.OnLoginFailed();
                break;

            case BVCU.BVCU_EVENT_SESSION_CLOSE:                     //关闭连接事件
                if (eventCommon.errorCode == BVCU.BVCU_RESULT_S_OK) //成功关闭连接
                {
                }
                else
                {
                    if (eventCommon.errorCode == BVCU.BVCU_RESULT_E.DISCONNECTED)
                    {
                        m_session.OnServerDisConnect();    //服务器下线
                        return;
                    }
                    return;
                }
                break;

            default:
                break;
            }
        }
예제 #2
0
        void Server_OnEvent(IntPtr session, int eventCode, ref BVCU_Event_Common eventCommon)
        {
            switch (eventCode)
            {
            case BVCU.BVCU_EVENT_SESSION_OPEN:
                if (eventCommon.errorCode == BVCU.BVCU_RESULT_S_OK)
                {
                    m_session.OnLoginOk();
                    return;
                }
                else if (eventCommon.errorCode == BVCU_RESULT_E.TIMEOUT)
                {
                }
                else if (eventCommon.errorCode == BVCU_RESULT_E.CONNECTFAILED)
                {
                }
                break;

            case BVCU.BVCU_EVENT_SESSION_CLOSE:
                if (eventCommon.errorCode == BVCU.BVCU_RESULT_S_OK)
                {
                }
                else
                {
                    if (eventCommon.errorCode == BVCU_RESULT_E.DISCONNECTED)
                    {
                        m_session.OnServerDisConnect();
                        return;
                    }
                    return;
                }
                break;

            default:
                break;
            }
        }