Exemple #1
0
        //包处理函数
        public void OnHandler(
            byte srcEndpoint,
            byte dstEndpoint,
            UInt16 keyModule,
            UInt32 keyAction,
            UInt32 sid,
            byte[] buffer, int nLen)
        {
            RealStatePtr L        = m_luaEnv.rawL;
            int          err_func = LuaAPI.load_error_func(L, m_errorFuncRef);


            LuaAPI.lua_getref(L, m_callbackFuncRef);

            LuaAPI.xlua_pushinteger(L, srcEndpoint);
            LuaAPI.xlua_pushinteger(L, dstEndpoint);
            LuaAPI.xlua_pushinteger(L, keyModule);
            LuaAPI.xlua_pushuint(L, keyAction);
            LuaAPI.xlua_pushuint(L, sid);
            LuaAPI.xlua_pushlstring(L, buffer, nLen);


            int __gen_error = LuaAPI.lua_pcall(L, 6, 0, err_func);

            if (__gen_error != 0)
            {
                m_luaEnv.ThrowExceptionFromError(err_func - 1);
            }

            LuaAPI.lua_settop(L, err_func - 1);
        }