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()); }
public override void Decode(Buffer buffer) { base.Decode(buffer); seq = buffer.ReadLong(); error = buffer.ReadInt(); }
public override void Decode(Buffer buffer) { var id = buffer.ReadInt(); if (id != Id) { throw new IOException($"消息ID不匹配,期望值[{Id}],实际值[{id}]"); } }