Beispiel #1
0
        public override void Decode(Buffer buffer)
        {
            base.Decode(buffer);

            seq   = buffer.ReadLong();
            error = buffer.ReadInt();
        }
Beispiel #2
0
        public static void Test1()
        {
            Console.WriteLine("Test1====================");

            var buffer = new Buffer();

            buffer.WriteBool(true);
            buffer.WriteInt(70);
            buffer.WriteInt(2423);
            buffer.WriteFloat(13.43F);
            buffer.WriteDouble(4242.432);
            buffer.WriteFloat(132.32434F, 2);
            buffer.WriteDouble(342254.653254, 2);
            buffer.WriteString("搭顺风车");
            buffer.WriteLong(12324);

            Console.WriteLine("buffer.ReadableCount:{0}", buffer.ReadableCount);

            var fileStream = File.Open("D:\\buffer", FileMode.Open);
            var bytes      = new byte[fileStream.Length];

            fileStream.Read(bytes, 0, bytes.Length);
            Console.WriteLine($"bytes.Length={bytes.Length}");
            buffer = new Buffer(bytes);

            Console.WriteLine(buffer.ReadBool());
            Console.WriteLine(buffer.ReadInt());
            Console.WriteLine(buffer.ReadInt());
            Console.WriteLine(buffer.ReadFloat());
            Console.WriteLine(buffer.ReadDouble());
            Console.WriteLine(buffer.ReadFloat(2));
            Console.WriteLine(buffer.ReadDouble(2));
            Console.WriteLine(buffer.ReadString());
            Console.WriteLine(buffer.ReadLong());
        }
Beispiel #3
0
        public override void Encode(Buffer buffer)
        {
            base.Encode(buffer);

            buffer.WriteLong(seq);
            buffer.WriteInt(error);
        }