You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 15:46:33 +09:00
NetServer.Disconnect added; Buffer.BlockCopy used in NetBitWriter
This commit is contained in:
@@ -72,8 +72,7 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
if (startReadAtIndex == 0)
|
if (startReadAtIndex == 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numberOfBytes; i++)
|
Buffer.BlockCopy(fromBuffer, readPtr, destination, destinationByteOffset, numberOfBytes);
|
||||||
destination[destinationByteOffset++] = fromBuffer[readPtr++];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,9 +145,7 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
if (firstPartLen == 0)
|
if (firstPartLen == 0)
|
||||||
{
|
{
|
||||||
// optimized; TODO: write 32 bit chunks if possible
|
Buffer.BlockCopy(source, sourceByteOffset, destination, dstBytePtr, numberOfBytes);
|
||||||
for (int i = 0; i < numberOfBytes; i++)
|
|
||||||
destination[dstBytePtr++] = source[sourceByteOffset + i];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,5 +29,10 @@ namespace Lidgren.Network
|
|||||||
// force this to true
|
// force this to true
|
||||||
config.AcceptIncomingConnections = true;
|
config.AcceptIncomingConnections = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Disconnect(NetConnection connection, string byeMessage)
|
||||||
|
{
|
||||||
|
connection.Disconnect(byeMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,18 @@ namespace UnitTests
|
|||||||
bool one = rdr.ReadBoolean();
|
bool one = rdr.ReadBoolean();
|
||||||
string hallon = rdr.ReadString();
|
string hallon = rdr.ReadString();
|
||||||
byte fourtyTwo = rdr.ReadByte();
|
byte fourtyTwo = rdr.ReadByte();
|
||||||
|
|
||||||
|
// test aligned WriteBytes/ReadBytes
|
||||||
|
msg = peer.CreateMessage();
|
||||||
|
byte[] tmparr = new byte[] { 5, 6, 7, 8, 9 };
|
||||||
|
msg.Write(tmparr);
|
||||||
|
|
||||||
|
inc = Program.CreateIncomingMessage(msg.PeekDataBuffer(), msg.LengthBits);
|
||||||
|
byte[] result = inc.ReadBytes(tmparr.Length);
|
||||||
|
|
||||||
|
for (int i = 0; i < tmparr.Length; i++)
|
||||||
|
if (tmparr[i] != result[i])
|
||||||
|
throw new Exception("readbytes fail");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user