Beispiel #1
0
 protected override void OnInit()
 {
     base.OnInit();
     AppLog.Debug("CoreTestModule OnInit");
     m_msgNetAgent        = new MsgNetAgent();
     m_msgHandler         = new TestMsgNetAgentHandler();
     m_msgHandler.m_owner = this;
     m_msgNetAgent.SetHandler(m_msgHandler);
     m_luaEnv = Lua.LuaUtil.NewLuaEnv();
 }
Beispiel #2
0
        protected static void ConnectResult(IAsyncResult ar)
        {
            if (ar.IsCompleted)
            {
                object[]           param  = ar.AsyncState as object[];
                ClientSocketCSharp pThis  = param[0] as ClientSocketCSharp;
                Socket             socket = param[1] as Socket;


                if (pThis.m_tmpSocket != socket)
                {
                    socket.Close();
                    socket = null;
                }
                else
                {
                    pThis.m_tmpSocket          = null;
                    pThis.m_threadParam.socket = socket;
                    if (null != pThis.m_tmpCnnCb)
                    {
                        bool isSucc = socket.Connected;
                        System.Action <bool> tmpCnnCb = pThis.m_tmpCnnCb;
                        pThis.m_asyncDoCnnCb = () => { tmpCnnCb(isSucc); };
                        pThis.m_tmpCnnCb     = null;
                    }
                    if (socket.Connected)
                    {
                        pThis.m_threadParam.state     = ClientSocketState.Connected;
                        pThis.m_threadParam.recvBytes = pThis.m_recvBytesArray[0];
                        pThis.m_threadParam.sendBytes = pThis.m_sendBytesArray[0];
                        pThis.m_threadParam.isExit    = false;
                        pThis.m_thread = new Thread(new ParameterizedThreadStart(ClientSocketCSharp.Loop));
                        pThis.m_thread.Start(pThis.m_threadParam);
                    }
                    else
                    {
                        pThis.m_threadParam.state = ClientSocketState.Error;
                    }
                }

                try
                {
                    socket.EndConnect(ar);
                }
                catch (System.Exception ex)
                {
                    AppLog.Debug("socket connect fail, exception message is {0}", ex.Message);
                }
            }
        }
Beispiel #3
0
 protected override void OnUpdate()
 {
     base.OnUpdate();
     AppLog.Debug("CoreTestModule OnUpdate");
 }
Beispiel #4
0
 public TestCoreModule(Core _app) : base(_app, EModule.TestModule)
 {
     AppLog.Debug("CoreTestModule new");
 }