Example #1
0
        public static bool Init(EPlatform ePlatform, bool isUseNetModule, ILPNetMessageHandler netMessageHandler)
        {
            bool bResult = false;

            bResult = _InitConfig(ePlatform);
            if (LPError.PTF_ERROR(bResult))
            {
                goto Exit0;
            }

            bResult = _InitLogger();
            if (LPError.PTF_ERROR(bResult))
            {
                goto Exit0;
            }

            if (isUseNetModule)
            {
                bResult = _InitNet(netMessageHandler);
                if (LPError.LOG_ERROR(bResult))
                {
                    goto Exit0;
                }
            }

            return(true);

Exit0:
            return(false);
        }
Example #2
0
        internal bool Init(ILPNetMessageHandler netMessageHandler)
        {
            bool bResult = false;

            Reactor = new LPReactor();
            if (LOG_ERROR(Reactor != null))
            {
                goto Exit0;
            }

            bResult = Reactor.Init();
            if (LOG_ERROR(bResult))
            {
                goto Exit0;
            }

            EventMgr = new LPNetEventMgr();
            if (LOG_ERROR(EventMgr != null))
            {
                goto Exit0;
            }

            bResult = EventMgr.Init(netMessageHandler, LP.NetEventListCount);
            if (LOG_ERROR(bResult))
            {
                goto Exit0;
            }

            m_ValidSockerList = new LPBaseList();
            if (LOG_ERROR(m_ValidSockerList != null))
            {
                goto Exit0;
            }

            m_DelayCloseList = new LPBaseList();
            if (LOG_ERROR(m_DelayCloseList != null))
            {
                goto Exit0;
            }

            m_DelayReleaseList = new LPBaseList();
            if (LOG_ERROR(m_DelayReleaseList != null))
            {
                goto Exit0;
            }

            m_CheckDelayRun    = true;
            m_CheckDelayThread = new Thread(_CheckDelayThreadProc);
            m_CheckDelayThread.Start();

            m_PostSendRun    = true;
            m_PostSendThread = new Thread(_PostSendThreadProc);
            m_PostSendThread.Start();

            return(true);

Exit0:
            return(false);
        }
Example #3
0
        private static bool _InitNet(ILPNetMessageHandler netMessageHandler)
        {
            bool bResult = false;

            m_NetModule = new LPNet();
            if (LPError.LOG_ERROR(m_NetModule != null))
            {
                goto Exit0;
            }

            bResult = m_NetModule.Init(netMessageHandler);
            if (LPError.LOG_ERROR(bResult))
            {
                goto Exit0;
            }

            return(true);

Exit0:
            return(false);
        }
Example #4
0
        internal bool Init(ILPNetMessageHandler netMessageHandler, int eventListCount)
        {
            bool result = false;

            if (LOG_ERROR(eventListCount > 0))
            {
                goto Exit0;
            }
            if (LOG_ERROR(netMessageHandler != null))
            {
                goto Exit0;
            }

            m_NetMessageHandler = netMessageHandler;

            m_EventBuf = new LPLoopBuf();
            if (LOG_ERROR(m_EventBuf != null))
            {
                goto Exit0;
            }

            result = m_EventBuf.Init(LP.NetEventBufSize);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            m_TempPacketBuf = new byte[LP.MaxPacketLen];
            if (LOG_ERROR(m_TempPacketBuf != null))
            {
                goto Exit0;
            }

            m_EventListCount = eventListCount;

            m_EventLists = new LPBaseList[m_EventListCount];
            if (LOG_ERROR(m_EventLists != null))
            {
                goto Exit0;
            }
            for (int i = 0; i < m_EventListCount; ++i)
            {
                m_EventLists[i] = new LPBaseList();
                if (LOG_ERROR(m_EventLists[i] != null))
                {
                    goto Exit0;
                }
            }

            m_EventListLocker = new object[m_EventListCount];
            if (LOG_ERROR(m_EventListLocker != null))
            {
                goto Exit0;
            }
            for (int i = 0; i < m_EventListCount; ++i)
            {
                m_EventListLocker[i] = new object();
                if (LOG_ERROR(m_EventListLocker[i] != null))
                {
                    goto Exit0;
                }
            }

            return(true);

Exit0:
            return(false);
        }