Beispiel #1
0
 public void UnMarshal(MMStream stream)
 {
     Source   = stream.ReadByte();
     UID      = stream.ReadUInt64();
     SourceID = stream.ReadUInt64();
     Type     = stream.ReadByte();
 }
Beispiel #2
0
 public void UnMarshal(MMStream stream)
 {
     spaceID   = stream.ReadUInt64();
     mapName   = stream.ReadString();
     entityID  = stream.ReadUInt64();
     outAddr   = stream.ReadString();
     timeStamp = stream.ReadUInt32();
 }
Beispiel #3
0
 public void UnMarshal(MMStream stream)
 {
     srvType    = stream.ReadByte();
     entityID   = stream.ReadUInt64();
     methodName = stream.ReadString();
     args       = stream.ReadBytes();
 }
Beispiel #4
0
        public void UnMarshal(MMStream stream)
        {
            entityId    = stream.ReadUInt64();
            adjustCount = stream.ReadUInt32();
            stream.ReadFixByteArray(ref stateData);



            //data = stream.ReadBytes();
        }
Beispiel #5
0
        public void UnMarshal(MMStream stream)
        {
            id = stream.ReadUInt64();

            int len        = stream.ReadUInt16();
            var marbytearr = statdata.getArray();

            stream.ReadBytes(ref marbytearr, len);

            //data = stream.ReadBytes();
        }
Beispiel #6
0
        public void UnMarshal(MMStream stream)
        {
            entityID = stream.ReadUInt64();
            num      = stream.ReadUInt32();
            //data = stream.ReadBytes();

            if (num > 1024)
            {
                throw new ArgumentNullException("PropSyncClient UnMarshal");
            }

            stream.ReadFixByteArray(ref data);
        }
Beispiel #7
0
        public void UnMarshal(MMStream stream)
        {
            id = stream.ReadUInt64();

            linkTarget = stream.ReadUInt64();

            var linkLength = stream.ReadByte();

            if (linkLength <= linkers.totalLength)
            {
                linkers.Clear();
            }
            else
            {
                linkers = new FixedLengthArray <ulong>(linkLength);
            }
            for (int i = 0; i < linkLength; i++)
            {
                linkers.Add(stream.ReadUInt64());
            }

            commTarget = stream.ReadUInt64();

            var commLength = stream.ReadByte();

            if (commLength <= commers.totalLength)
            {
                commers.Clear();
            }
            else
            {
                commers = new FixedLengthArray <ulong>(commLength);
            }
            for (int i = 0; i < commLength; i++)
            {
                commers.Add(stream.ReadUInt64());
            }
        }
Beispiel #8
0
        public void UnMarshal(MMStream stream)
        {
            entityID   = stream.ReadUInt64();
            entityType = stream.ReadString();
            state      = stream.ReadBytes();
            propNum    = stream.ReadUInt16();
            properties = stream.ReadBytes();

            var len = stream.ReadUInt16();

            if (len == 0)
            {
                baseProps = null;
            }
            else
            {
                baseProps = new EntityBaseProps();
                baseProps.UnMarshal(stream);
            }
        }
Beispiel #9
0
        public void UnMarshal(MMStream stream)
        {
            num = stream.ReadUInt32();

            eids.Clear();

            eds.SetUsedLength((int)num);

            for (int i = 0; i < num; i++)
            {
                eids.Add(stream.ReadUInt64());

                //int blen = stream.ReadUInt16();

                var edsbytearr = eds.getArray()[i];
                if (edsbytearr == null)
                {
                    eds.getArray()[i] = new FixedLengthArray <byte>(2048);
                    edsbytearr        = eds.getArray()[i];
                }

                stream.ReadFixByteArray(ref edsbytearr);
            }
        }
Beispiel #10
0
        private static object doUnpack(MMStream stream, Type type)
        {
            //if (stream.IsEOF())
            //    return null;

            //Debug.Log("doUnpack type:" + type + " type.IsValueType:" + type.IsValueType + " type.IsArray:" + type.IsArray);

            if (!stream.IsEOF())
            {
                if (type == typeof(byte))
                {
                    return(stream.ReadByte());
                }
                else if (type == typeof(sbyte))
                {
                    return((sbyte)stream.ReadByte());
                }
                else if (type == typeof(ushort))
                {
                    return(stream.ReadUInt16());
                }
                else if (type == typeof(uint))
                {
                    return(stream.ReadUInt32());
                }
                else if (type == typeof(ulong))
                {
                    return(stream.ReadUInt64());
                }
                else if (type == typeof(short))
                {
                    return(stream.ReadInt16());
                }
                else if (type == typeof(int))
                {
                    return(stream.ReadInt32());
                }
                else if (type == typeof(long))
                {
                    return(stream.ReadInt64());
                }
                else if (type == typeof(float))
                {
                    return(stream.ReadFloat());
                }
                else if (type == typeof(double))
                {
                    return(stream.ReadDouble());
                }
                else if (type == typeof(string))
                {
                    return(stream.ReadString());
                }
                else if (type == typeof(byte[]))
                {
                    return(stream.ReadBytes());
                }
                else if (type == typeof(sbyte[]))
                {
                    var buff  = stream.ReadBytes();
                    var sbuff = new sbyte[buff.Length];
                    Array.Copy(buff, sbuff, buff.Length);
                    return(sbuff);
                }
                else if (type == typeof(bool))
                {
                    return(stream.ReadBoolean());
                }
                else if (type.IsArray)
                {
                    var    count  = stream.ReadUInt16();
                    object newobj = Array.CreateInstance(type.GetElementType(), count);

                    for (var i = 0; i < count; i++)
                    {
                        var val = doUnpack(stream, type.GetElementType());
                        newobj.GetType().GetMethod("SetValue", new Type[2] {
                            typeof(object), typeof(int)
                        }).Invoke(newobj, new object[] { val, i });
                    }

                    return(newobj);
                }
                else if (typeof(IDictionary).IsAssignableFrom(type))
                {
                    var count    = stream.ReadUInt16();
                    var eletypes = type.GetGenericArguments();
                    var newdict  = Activator.CreateInstance(type) as IDictionary;

                    for (var i = 0; i < count; i++)
                    {
                        var key = doUnpack(stream, eletypes[0]);
                        var val = doUnpack(stream, eletypes[1]);
                        newdict[key] = val;
                    }
                    return(newdict);
                }
                else if (typeof(IList).IsAssignableFrom(type))
                {
                    var count   = stream.ReadUInt16();
                    var newlist = Activator.CreateInstance(type) as IList;
                    var eletype = type.GetGenericArguments()[0];//.GetElementType();

                    for (var i = 0; i < count; i++)
                    {
                        newlist.Add(doUnpack(stream, eletype));
                    }
                    return(newlist);
                }
            }

            if (typeof(ProtoBuf.IExtensible).IsAssignableFrom(type))
            {
                System.IO.MemoryStream pstream = null;
                if (stream.IsEOF())
                {
                    pstream = new System.IO.MemoryStream();
                }
                else
                {
                    var msgBuf = stream.ReadBytes();

                    pstream = new System.IO.MemoryStream(msgBuf, 0, msgBuf.Length);
                    pstream.SetLength(msgBuf.Length);
                }

                return(ProtoBuf.Meta.RuntimeTypeModel.Default.Deserialize(pstream, null, type));
            }
            else if (type.IsEnum)
            {
                object newobj = Activator.CreateInstance(type);

                if (!stream.IsEOF())
                {
                    var fields = newobj.GetType().GetFields();

                    var field = fields[0];
                    var val   = doUnpack(stream, field.FieldType);
                    //var index = type.IsArray ? new object[] { i } : null;
                    field.SetValue(newobj, val);
                }

                return(newobj);
            }
            else if (type.IsValueType || type.IsClass)
            {
                object newobj = Activator.CreateInstance(type);

                if (!stream.IsEOF())
                {
                    var fields = newobj.GetType().GetFields();

                    for (var i = 0; i < fields.Length; i++)
                    {
                        var field = fields[i];
                        var val   = doUnpack(stream, field.FieldType);
                        //var index = type.IsArray ? new object[] { i } : null;
                        field.SetValue(newobj, val);
                    }
                }

                return(newobj);
            }
            else
            {
                throw new NotSupportedException("Unknow rpc method param type: [" + type.Name + "]");
            }
        }
Beispiel #11
0
 public void UnMarshal(MMStream stream)
 {
     Source = stream.ReadByte();
     UID    = stream.ReadUInt64();
     Token  = stream.ReadBytes(Token.Length);
 }
Beispiel #12
0
 public void UnMarshal(MMStream stream)
 {
     entityID   = stream.ReadUInt64();
     propNum    = stream.ReadUInt32();
     properties = stream.ReadBytes();
 }
Beispiel #13
0
 public void UnMarshal(MMStream stream)
 {
     entityID = stream.ReadUInt64();
 }