Added TShock.SendBytes which uses packetbuffer if available, otherwise sends like normal.

This commit is contained in:
high 2011-08-12 23:17:23 -04:00
parent 2ed91e26a0
commit 258b7d48fb
4 changed files with 44 additions and 19 deletions

View file

@ -123,9 +123,13 @@ namespace TShockAPI
buffers[socket.whoAmI] = new PacketBuffer();
}
void ServerHooks_SendBytes(ServerSock socket, byte[] buffer, int offset, int count, HandledEventArgs e)
public void SendBytes(ServerSock socket, byte[] buffer)
{
SendBytes(socket, buffer, 0, buffer.Length);
}
public void SendBytes(ServerSock socket, byte[] buffer, int offset, int count)
{
e.Handled = true;
lock (buffers[socket.whoAmI])
{
#if DEBUG_NET
@ -142,6 +146,12 @@ namespace TShockAPI
}
}
}
void ServerHooks_SendBytes(ServerSock socket, byte[] buffer, int offset, int count, HandledEventArgs e)
{
e.Handled = true;
SendBytes(socket, buffer, offset, count);
}
#if DEBUG_NET
static int Compress(byte[] buffer, int offset, int count)
{