Ejemplo n.º 1
0
        public static int CreateThread(int channel, string recvFileName, string recvClassName, bool main, int sleepTime)
        {
            if (createdThread.ContainsKey(channel))
            {
                return(-1000);
            }
            LuaContext luaContext;

            if (main)
            {
                luaContext = LuaManager.GetLuaContext();
            }
            else
            {
                //luaContext = new LuaContext(LuaManager.GetRegisterGameCall());
                luaContext = LuaContext.Create(LuaManager.GetRegisterGameCall());
                luaContext.RegisterLibs();

                DllHelper.SNavLua_Init(luaContext.GetLuaState().GetL());
            }

            luaContext.Require(recvFileName);
            LuaFunction initFunc   = luaContext.GetFunction(recvClassName + ".Init");
            LuaFunction updateFunc = luaContext.GetFunction(recvClassName + ".Update");

            int re = sthread_lcreate(luaContext.GetLuaState().GetL(), channel, initFunc.GetReference(), updateFunc.GetReference(), sleepTime);

            if (re >= 0)
            {
                createdThread.Add(channel, luaContext);
            }

            return(re);
        }