Major rewrite of the packet sending code:
* Automatic packet splitting. You can send packets with any number of blocks and the networking layer will split them up automatically * Less memory is allocated for outgoing packet buffers * Memory is only allocated for zerocoding (outgoing and incoming) when it is needed * A lockless queue is used to hold outgoing ACKs * ACKs are stuffed into packets until they hit the MTU * All outgoing packets are serialized exactly once, instead of serializing every resend * Improved the clarity of the networking layer (I will upload a flow chart of packet sending soon) git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2800 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -394,6 +394,7 @@ namespace mapgenerator
|
||||
|
||||
static void WritePacketClass(TextWriter writer, MapPacket packet)
|
||||
{
|
||||
bool hasVariableBlocks = false;
|
||||
string sanitizedName;
|
||||
|
||||
//writer.WriteLine(" /// <summary>" + packet.Name + " packet</summary>");
|
||||
@@ -420,6 +421,8 @@ namespace mapgenerator
|
||||
|
||||
if (block.Count == -1)
|
||||
{
|
||||
hasVariableBlocks = true;
|
||||
|
||||
// Variable count block
|
||||
writer.WriteLine(" for (int j = 0; j < " + sanitizedName + ".Length; j++)");
|
||||
writer.WriteLine(" length += " + sanitizedName + "[j].Length;");
|
||||
@@ -455,6 +458,7 @@ namespace mapgenerator
|
||||
// Default constructor
|
||||
//writer.WriteLine(" /// <summary>Default constructor</summary>");
|
||||
writer.WriteLine(" public " + packet.Name + "Packet()" + Environment.NewLine + " {");
|
||||
writer.WriteLine(" HasVariableBlocks = " + hasVariableBlocks.ToString().ToLowerInvariant() + ";");
|
||||
writer.WriteLine(" Type = PacketType." + packet.Name + ";");
|
||||
writer.WriteLine(" Header = new Header();");
|
||||
writer.WriteLine(" Header.Frequency = PacketFrequency." + packet.Frequency + ";");
|
||||
@@ -978,6 +982,7 @@ namespace mapgenerator
|
||||
" public const int MTU = 1200;" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
" public Header Header;" + Environment.NewLine +
|
||||
" public bool HasVariableBlocks;" + Environment.NewLine +
|
||||
" public PacketType Type;" + Environment.NewLine +
|
||||
" public abstract int Length { get; }" + Environment.NewLine +
|
||||
" public abstract void FromBytes(byte[] bytes, ref int i, ref int packetEnd, byte[] zeroBuffer);" + Environment.NewLine +
|
||||
|
||||
Reference in New Issue
Block a user