Esempio n. 1
0
    public IRltProto CreateLuaProto(ushort id, ByteBuffer buffer, ref int protocolLen)
    {
        if (propsJsonDict.ContainsKey(id))
        {
            var props = propsJsonDict[id];

            /**
             * 暂时不用吧
             */
            // if (props.NeedCompress)
            // {
            //     int decompressLen = buffer.Decompress(protocolLen - 2);
            //     protocolLen = decompressLen + 2;
            // }
            var ret = new RltLuaMessage();
            ret.ID = id;
            SerializeJsonTools.FillObject(ret.Data, props, buffer, 1);
            return(ret);
        }
        else
        {
            Debug.LogError("协议 id " + id + "未定义");
            return(null);
        }
    }
Esempio n. 2
0
    public byte[] GetLuaProtocolBytes(ReqLuaMessage protocol)
    {
        try
        {
            var bytes = new List <byte>();
            var props = propsJsonDict[protocol.ID];
            var data  = JObject.Parse(protocol.Data);
            for (int i = 1; i < props.Table.Length; i++)
            {
                bytes.AddRange(SerializeJsonTools.GetObjectBytes(data, props.Table[i]));
            }
            var result = bytes.ToArray();

            /**
             * 暂时先不用吧
             */
            // if (props.NeedCompress)
            // {
            //     result = CompressionHelper.ZipCompress(result);
            // }
            return(result);
        }
        catch (Exception e)
        {
            UnityEngine.Debug.Log("slf GetLuaProtocolBytes ID:" + protocol.ID + " e:" + e.ToString());
            return(null);
        }
    }