Implementing Packet Framing
Surrounding packets with Int32 6655 to identify packet structure
This commit is contained in:
@@ -104,15 +104,18 @@ namespace Articulate_Network.Managers
|
||||
//Console.WriteLine(field.Name);
|
||||
}
|
||||
|
||||
long length = buffer.Length;
|
||||
byte[] packetData = buffer.ToArray();
|
||||
long length = packetData.Length;
|
||||
|
||||
buffer.SetLength(0);
|
||||
|
||||
binaryWriter.Write(6655);
|
||||
binaryWriter.Write(length);
|
||||
binaryWriter.Write(packetData);
|
||||
binaryWriter.Write(length);
|
||||
|
||||
//Console.WriteLine("Sent bytes: " + length);
|
||||
|
||||
watch.Stop();
|
||||
|
||||
//Console.WriteLine($"Serialize time: {watch.ElapsedTicks / 10} microseconds");
|
||||
@@ -127,7 +130,7 @@ namespace Articulate_Network.Managers
|
||||
|
||||
string typeName = reader.ReadString();
|
||||
|
||||
Console.WriteLine(typeName);
|
||||
//Console.WriteLine(typeName);
|
||||
|
||||
Packet packet = packetInstances[typeName];/*(IPacket)Activator.CreateInstance(typeof(T));*/
|
||||
|
||||
@@ -160,6 +163,8 @@ namespace Articulate_Network.Managers
|
||||
}
|
||||
}
|
||||
|
||||
reader.ReadInt64();
|
||||
|
||||
watch.Stop();
|
||||
|
||||
//Console.WriteLine($"Deserialize time: {watch.ElapsedTicks / 10} microseconds");
|
||||
|
||||
Reference in New Issue
Block a user