Esempio n. 1
0
 private Sio.SData format_List(IntPtr L, int index, NParam o)
 {
     Sio.SListWriter pl = new Sio.SListWriter();
     Sio.SData       d  = new Sio.SData(pl);
     if (LuaAPI.lua_istable(L, index))
     {
         int indexsize = (int)LuaAPI.xlua_objlen(L, index);
         for (int list_index = 1; list_index <= indexsize; ++list_index)
         {
             LuaAPI.xlua_rawgeti(L, index, list_index);
             Sio.SData td = format_data(o, L, LuaAPI.lua_gettop(L), false);
             pl.add(td);
             LuaAPI.lua_pop(L, 1);
         }
     }
     return(d);
 }
Esempio n. 2
0
    private void push_list(SDataBuff data, NParam o, IntPtr L)
    {
        Sio.SListReader plist = data.listReader;
        LuaAPI.lua_newtable(L);
        int top_index = LuaAPI.lua_gettop(L);
        int luaindex  = 0;

        if (plist != null && o.Container == ParamContainer.pparam_container_list)
        {
            Sio.SDataBuff d = new Sio.SDataBuff();
            while (plist.Next(d))
            {
                push_data(d, L, o);
                LuaAPI.xlua_rawseti(L, top_index, ++luaindex);
            }
        }
    }
Esempio n. 3
0
    public bool Process(Core.Net.Client c, Core.Net.Package p, int messageid, SNet.NFunction pf)
    {
        if (c.isConnected)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(pf.Nm.Name);
            sb.Append(".");
            sb.Append(pf.Name);

            Logger.Log(string.Format("<color=#00ab00ff>>>>receive<<<,msgid:{0}({1})</color>", messageid, sb.ToString()));

            if (null != this.OnReceive)
            {
                this.OnReceive(messageid, p.Header.GetExtData(), p.Header.GetSeqNum());
            }

            if (null != this.OnReceivePackage)
            {
                this.OnReceivePackage(messageid, p.Data);
            }

//		    LuaFunction func = XLuaManager.Instance.GetLuaEnv().Global.Get<LuaFunction>(c.DispatchFunc);
            if (null != this.DispatchFunc)
            {
                var luaEnv = XLuaManager.Instance.GetLuaEnv();
                var L      = luaEnv.L;

                var translator = luaEnv.translator;
                int oldTop     = LuaAPI.lua_gettop(L);

                int errFunc = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
                LuaAPI.lua_getref(L, this.DispatchFunc.GetLuaReference());

                translator.PushAny(L, c.SocketID);
                translator.PushAny(L, messageid);
                translator.PushAny(L, p.Header.GetExtData());
                translator.PushAny(L, p.Header.GetSeqNum());
                translator.PushAny(L, sb.ToString());
                int valueCount = 5;


                IList <NParam> param_list = pf.ParamList;
                if (p.Data != null)
                {
                    MemoryStream ms = new MemoryStream(p.Data);
                    for (int i = 0; i < param_list.Count; i++)
                    {
                        push_to_lua(param_list[i], ms, L);
                        valueCount++;
                    }
                }

                int error = LuaAPI.lua_pcall(L, valueCount, -1, errFunc);
                if (error != 0)
                {
                    luaEnv.ThrowExceptionFromError(oldTop);
                }

                LuaAPI.lua_remove(L, errFunc);
            }
        }

        return(true);
    }