Deprecated PacketBufferer as its function is now fulfilled by SendQ
This commit is contained in:
parent
7d4a96cfee
commit
9c7d0f08e2
4 changed files with 37 additions and 33 deletions
|
|
@ -186,6 +186,7 @@ namespace TShockAPI
|
||||||
[Description("Valid types are \"sha512\", \"sha256\", \"md5\", append with \"-xp\" for the xp supported algorithms.")]
|
[Description("Valid types are \"sha512\", \"sha256\", \"md5\", append with \"-xp\" for the xp supported algorithms.")]
|
||||||
public string HashAlgorithm = "sha512";
|
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.")]
|
[Description("Buffers up the packets and sends them out at the end of each frame.")]
|
||||||
public bool BufferPackets = true;
|
public bool BufferPackets = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ using TerrariaApi.Server;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
[Obsolete("This class is no longer used")]
|
||||||
public class PacketBufferer : IDisposable
|
public class PacketBufferer : IDisposable
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum number of bytes to send per update per socket
|
/// Maximum number of bytes to send per update per socket
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -46,10 +48,10 @@ namespace TShockAPI
|
||||||
Command dump;
|
Command dump;
|
||||||
Command flush;
|
Command flush;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
public PacketBufferer(TShock p)
|
public PacketBufferer(TShock p)
|
||||||
{
|
{
|
||||||
plugin = p;
|
/*plugin = p;
|
||||||
BytesPerUpdate = 0xFFFF;
|
BytesPerUpdate = 0xFFFF;
|
||||||
for (int i = 0; i < buffers.Length; i++)
|
for (int i = 0; i < buffers.Length; i++)
|
||||||
buffers[i] = new PacketBuffer();
|
buffers[i] = new PacketBuffer();
|
||||||
|
|
@ -63,23 +65,23 @@ namespace TShockAPI
|
||||||
|
|
||||||
ServerApi.Hooks.NetSendBytes.Register(plugin, ServerHooks_SendBytes);
|
ServerApi.Hooks.NetSendBytes.Register(plugin, ServerHooks_SendBytes);
|
||||||
ServerApi.Hooks.ServerSocketReset.Register(plugin, ServerHooks_SocketReset);
|
ServerApi.Hooks.ServerSocketReset.Register(plugin, ServerHooks_SocketReset);
|
||||||
ServerApi.Hooks.GamePostUpdate.Register(plugin, GameHooks_Update);
|
ServerApi.Hooks.GamePostUpdate.Register(plugin, GameHooks_Update);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
~PacketBufferer()
|
~PacketBufferer()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
/*Dispose(false);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
/*Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
/*if (disposing)
|
||||||
{
|
{
|
||||||
#if DEBUG_NET
|
#if DEBUG_NET
|
||||||
Commands.ChatCommands.Remove(dump);
|
Commands.ChatCommands.Remove(dump);
|
||||||
|
|
@ -88,44 +90,44 @@ namespace TShockAPI
|
||||||
ServerApi.Hooks.NetSendBytes.Deregister(plugin, ServerHooks_SendBytes);
|
ServerApi.Hooks.NetSendBytes.Deregister(plugin, ServerHooks_SendBytes);
|
||||||
ServerApi.Hooks.ServerSocketReset.Deregister(plugin, ServerHooks_SocketReset);
|
ServerApi.Hooks.ServerSocketReset.Deregister(plugin, ServerHooks_SocketReset);
|
||||||
ServerApi.Hooks.GamePostUpdate.Deregister(plugin, GameHooks_Update);
|
ServerApi.Hooks.GamePostUpdate.Deregister(plugin, GameHooks_Update);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Dump(CommandArgs args)
|
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"));
|
sb.AppendLine("{0,-25}{1,-25}{2,-25}{3}".SFormat("Name:", "Packets", "Bytes", "Compression"));
|
||||||
for (int i = 1; i < Bytes.Length; i++)
|
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],
|
sb.AppendLine("{0,-25}{1,-25}{2,-25}{3}".SFormat(Enum.GetName(typeof (PacketTypes), i) + ":", Packets[i], Bytes[i],
|
||||||
Compressed[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)
|
private void Flush(CommandArgs args)
|
||||||
{
|
{
|
||||||
Bytes = new int[52];
|
/*Bytes = new int[52];
|
||||||
Packets = new int[52];
|
Packets = new int[52];
|
||||||
Compressed = new int[52];
|
Compressed = new int[52];*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameHooks_Update(EventArgs args)
|
private void GameHooks_Update(EventArgs args)
|
||||||
{
|
{
|
||||||
FlushAll();
|
/*FlushAll();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void 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]);
|
Flush(Netplay.Clients[i]);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Flush(RemoteClient client)
|
public bool Flush(RemoteClient client)
|
||||||
{
|
{
|
||||||
try
|
/*try
|
||||||
{
|
{
|
||||||
if (client == null || !client.IsActive)
|
if (client == null || !client.IsActive)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -149,29 +151,30 @@ namespace TShockAPI
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
TShock.Log.ConsoleError(e.ToString());
|
TShock.Log.ConsoleError(e.ToString());
|
||||||
}
|
}*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ServerHooks_SocketReset(SocketResetEventArgs args)
|
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)
|
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)
|
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)
|
public void BufferBytes(RemoteClient client, byte[] buffer, int offset, int count)
|
||||||
{
|
{
|
||||||
lock (buffers[client.Id])
|
/*lock (buffers[client.Id])
|
||||||
{
|
{
|
||||||
#if DEBUG_NET
|
#if DEBUG_NET
|
||||||
int size = (count - offset);
|
int size = (count - offset);
|
||||||
|
|
@ -191,12 +194,12 @@ namespace TShockAPI
|
||||||
buffers[client.Id].Clear();
|
buffers[client.Id].Clear();
|
||||||
client.PendingTermination = true;
|
client.PendingTermination = true;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SendBytes(RemoteClient client, byte[] buffer, int offset, int count)
|
public bool SendBytes(RemoteClient client, byte[] buffer, int offset, int count)
|
||||||
{
|
{
|
||||||
try
|
/*try
|
||||||
{
|
{
|
||||||
if (client.Socket != null && client.Socket.IsConnected())
|
if (client.Socket != null && client.Socket.IsConnected())
|
||||||
{
|
{
|
||||||
|
|
@ -239,16 +242,16 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TShock.Log.Warn(e.ToString());
|
TShock.Log.Warn(e.ToString());
|
||||||
}
|
}*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ServerHooks_SendBytes(SendBytesEventArgs args)
|
private void ServerHooks_SendBytes(SendBytesEventArgs args)
|
||||||
{
|
{
|
||||||
args.Handled = true;
|
/*args.Handled = true;
|
||||||
BufferBytes(args.Socket, args.Buffer, args.Offset, args.Count);
|
BufferBytes(args.Socket, args.Buffer, args.Offset, args.Count);*/
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
#if DEBUG_NET
|
#if DEBUG_NET
|
||||||
static int Compress(byte[] buffer, int offset, int count)
|
static int Compress(byte[] buffer, int offset, int count)
|
||||||
{
|
{
|
||||||
|
|
@ -262,11 +265,13 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("This class is no longer used")]
|
||||||
public class PacketBuffer : List<byte>
|
public class PacketBuffer : List<byte>
|
||||||
{
|
{
|
||||||
public byte[] GetBytes(int max)
|
/*public byte[] GetBytes(int max)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
|
|
@ -285,6 +290,6 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
this.RemoveRange(0, count);
|
this.RemoveRange(0, count);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -565,7 +565,7 @@ namespace TShockAPI
|
||||||
if (client == null)
|
if (client == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TShock.PacketBuffer.Flush(client);
|
//TShock.PacketBuffer.Flush(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ namespace TShockAPI
|
||||||
/// <summary>OverridePort - Determines if TShock should override the server port.</summary>
|
/// <summary>OverridePort - Determines if TShock should override the server port.</summary>
|
||||||
public static bool OverridePort;
|
public static bool OverridePort;
|
||||||
/// <summary>PacketBuffer - Static reference to the packet bufferer system, which buffers packets to clients for better performance.</summary>
|
/// <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;
|
public static PacketBufferer PacketBuffer;
|
||||||
/// <summary>Geo - Static reference to the GeoIP system which determines the location of an IP address.</summary>
|
/// <summary>Geo - Static reference to the GeoIP system which determines the location of an IP address.</summary>
|
||||||
public static GeoIPCountry Geo;
|
public static GeoIPCountry Geo;
|
||||||
|
|
@ -322,9 +323,6 @@ namespace TShockAPI
|
||||||
if (Config.RestApiEnabled)
|
if (Config.RestApiEnabled)
|
||||||
RestApi.Start();
|
RestApi.Start();
|
||||||
|
|
||||||
if (Config.BufferPackets)
|
|
||||||
PacketBuffer = new PacketBufferer(this);
|
|
||||||
|
|
||||||
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
|
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
|
||||||
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
|
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue