Deprecated PacketBufferer as its function is now fulfilled by SendQ

This commit is contained in:
White 2015-11-23 11:50:24 +10:30
parent 7d4a96cfee
commit 9c7d0f08e2
4 changed files with 37 additions and 33 deletions

View file

@ -186,6 +186,7 @@ namespace TShockAPI
[Description("Valid types are \"sha512\", \"sha256\", \"md5\", append with \"-xp\" for the xp supported algorithms.")]
public string HashAlgorithm = "sha512";
[Obsolete("PacketBuffered is no longer used")]
[Description("Buffers up the packets and sends them out at the end of each frame.")]
public bool BufferPackets = true;

View file

@ -27,8 +27,10 @@ using TerrariaApi.Server;
namespace TShockAPI
{
[Obsolete("This class is no longer used")]
public class PacketBufferer : IDisposable
{
/*
/// <summary>
/// Maximum number of bytes to send per update per socket
/// </summary>
@ -46,10 +48,10 @@ namespace TShockAPI
Command dump;
Command flush;
#endif
*/
public PacketBufferer(TShock p)
{
plugin = p;
/*plugin = p;
BytesPerUpdate = 0xFFFF;
for (int i = 0; i < buffers.Length; i++)
buffers[i] = new PacketBuffer();
@ -63,23 +65,23 @@ namespace TShockAPI
ServerApi.Hooks.NetSendBytes.Register(plugin, ServerHooks_SendBytes);
ServerApi.Hooks.ServerSocketReset.Register(plugin, ServerHooks_SocketReset);
ServerApi.Hooks.GamePostUpdate.Register(plugin, GameHooks_Update);
ServerApi.Hooks.GamePostUpdate.Register(plugin, GameHooks_Update);*/
}
~PacketBufferer()
{
Dispose(false);
/*Dispose(false);*/
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
/*Dispose(true);
GC.SuppressFinalize(this);*/
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
/*if (disposing)
{
#if DEBUG_NET
Commands.ChatCommands.Remove(dump);
@ -88,44 +90,44 @@ namespace TShockAPI
ServerApi.Hooks.NetSendBytes.Deregister(plugin, ServerHooks_SendBytes);
ServerApi.Hooks.ServerSocketReset.Deregister(plugin, ServerHooks_SocketReset);
ServerApi.Hooks.GamePostUpdate.Deregister(plugin, GameHooks_Update);
}
}*/
}
private void Dump(CommandArgs args)
{
var sb = new StringBuilder();
/*var sb = new StringBuilder();
sb.AppendLine("{0,-25}{1,-25}{2,-25}{3}".SFormat("Name:", "Packets", "Bytes", "Compression"));
for (int i = 1; i < Bytes.Length; i++)
{
sb.AppendLine("{0,-25}{1,-25}{2,-25}{3}".SFormat(Enum.GetName(typeof (PacketTypes), i) + ":", Packets[i], Bytes[i],
Compressed[i]));
}
File.WriteAllText(Path.Combine(TShock.SavePath, "dmp.txt"), sb.ToString());
File.WriteAllText(Path.Combine(TShock.SavePath, "dmp.txt"), sb.ToString());*/
}
private void Flush(CommandArgs args)
{
Bytes = new int[52];
/*Bytes = new int[52];
Packets = new int[52];
Compressed = new int[52];
Compressed = new int[52];*/
}
private void GameHooks_Update(EventArgs args)
{
FlushAll();
/*FlushAll();*/
}
public void FlushAll()
{
for (int i = 0; i < Netplay.Clients.Length; i++)
/*for (int i = 0; i < Netplay.Clients.Length; i++)
{
Flush(Netplay.Clients[i]);
}
}*/
}
public bool Flush(RemoteClient client)
{
try
/*try
{
if (client == null || !client.IsActive)
return false;
@ -149,29 +151,30 @@ namespace TShockAPI
catch (Exception e)
{
TShock.Log.ConsoleError(e.ToString());
}
}*/
return false;
}
private void ServerHooks_SocketReset(SocketResetEventArgs args)
{
buffers[args.Socket.Id] = new PacketBuffer();
/*buffers[args.Socket.Id] = new PacketBuffer();*/
}
public bool SendBytes(RemoteClient client, byte[] buffer)
{
return SendBytes(client, buffer, 0, buffer.Length);
/*return SendBytes(client, buffer, 0, buffer.Length);*/
return false;
}
public void BufferBytes(RemoteClient client, byte[] buffer)
{
BufferBytes(client, buffer, 0, buffer.Length);
/*BufferBytes(client, buffer, 0, buffer.Length);*/
}
public void BufferBytes(RemoteClient client, byte[] buffer, int offset, int count)
{
lock (buffers[client.Id])
/*lock (buffers[client.Id])
{
#if DEBUG_NET
int size = (count - offset);
@ -191,12 +194,12 @@ namespace TShockAPI
buffers[client.Id].Clear();
client.PendingTermination = true;
}
}
}*/
}
public bool SendBytes(RemoteClient client, byte[] buffer, int offset, int count)
{
try
/*try
{
if (client.Socket != null && client.Socket.IsConnected())
{
@ -239,16 +242,16 @@ namespace TShockAPI
}
else
TShock.Log.Warn(e.ToString());
}
}*/
return false;
}
private void ServerHooks_SendBytes(SendBytesEventArgs args)
{
args.Handled = true;
BufferBytes(args.Socket, args.Buffer, args.Offset, args.Count);
/*args.Handled = true;
BufferBytes(args.Socket, args.Buffer, args.Offset, args.Count);*/
}
/*
#if DEBUG_NET
static int Compress(byte[] buffer, int offset, int count)
{
@ -262,11 +265,13 @@ namespace TShockAPI
}
}
#endif
*/
}
[Obsolete("This class is no longer used")]
public class PacketBuffer : List<byte>
{
public byte[] GetBytes(int max)
/*public byte[] GetBytes(int max)
{
lock (this)
{
@ -285,6 +290,6 @@ namespace TShockAPI
{
this.RemoveRange(0, count);
}
}
}*/
}
}

View file

@ -565,7 +565,7 @@ namespace TShockAPI
if (client == null)
return;
TShock.PacketBuffer.Flush(client);
//TShock.PacketBuffer.Flush(client);
}

View file

@ -100,6 +100,7 @@ namespace TShockAPI
/// <summary>OverridePort - Determines if TShock should override the server port.</summary>
public static bool OverridePort;
/// <summary>PacketBuffer - Static reference to the packet bufferer system, which buffers packets to clients for better performance.</summary>
[Obsolete("PacketBufferer is no longer used", true)]
public static PacketBufferer PacketBuffer;
/// <summary>Geo - Static reference to the GeoIP system which determines the location of an IP address.</summary>
public static GeoIPCountry Geo;
@ -322,9 +323,6 @@ namespace TShockAPI
if (Config.RestApiEnabled)
RestApi.Start();
if (Config.BufferPackets)
PacketBuffer = new PacketBufferer(this);
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));