fix(core): Removes disposable netstates. (#467)
- [X] Removes IDisposable from NetState - [X] Swaps Disconnect and Dispose methods
This commit is contained in:
parent
079eeb1b96
commit
67625ad249
49 changed files with 204 additions and 210 deletions
|
|
@ -35,7 +35,7 @@ namespace Server.Network
|
|||
public delegate void DecodePacket(CircularBuffer<byte> buffer, ref int length);
|
||||
public delegate void EncodePacket(ReadOnlySpan<byte> inputBuffer, CircularBuffer<byte> outputBuffer, out int length);
|
||||
|
||||
public partial class NetState : IComparable<NetState>, IDisposable
|
||||
public partial class NetState : IComparable<NetState>
|
||||
{
|
||||
private static int RecvPipeSize = 1024 * 64 + 1;
|
||||
private static int SendPipeSize = 1024 * 256 + 1;
|
||||
|
|
@ -270,7 +270,7 @@ namespace Server.Network
|
|||
else
|
||||
{
|
||||
WriteConsole("Exceeded menu cap, disconnecting...");
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ namespace Server.Network
|
|||
else
|
||||
{
|
||||
WriteConsole("Exceeded hue picker cap, disconnecting...");
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ namespace Server.Network
|
|||
else
|
||||
{
|
||||
WriteConsole("Exceeded gump cap, disconnecting...");
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ namespace Server.Network
|
|||
Console.WriteLine(ex);
|
||||
TraceException(ex);
|
||||
#endif
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ namespace Server.Network
|
|||
else
|
||||
{
|
||||
WriteConsole("Too much data pending, disconnecting...");
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -468,7 +468,7 @@ namespace Server.Network
|
|||
Console.WriteLine(ex);
|
||||
TraceException(ex);
|
||||
#endif
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -526,7 +526,7 @@ namespace Server.Network
|
|||
}
|
||||
finally
|
||||
{
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -585,7 +585,7 @@ namespace Server.Network
|
|||
}
|
||||
finally
|
||||
{
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -633,7 +633,7 @@ namespace Server.Network
|
|||
// TODO: Throw exception instead?
|
||||
if (bytesProcessed < 0)
|
||||
{
|
||||
Dispose();
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -649,7 +649,7 @@ namespace Server.Network
|
|||
Console.WriteLine(ex);
|
||||
TraceException(ex);
|
||||
#endif
|
||||
Dispose();
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -675,7 +675,7 @@ namespace Server.Network
|
|||
|
||||
while (Disposed.TryDequeue(out var ns))
|
||||
{
|
||||
ns.Disconnect();
|
||||
ns.Dispose();
|
||||
TcpServer.Instances.Remove(ns);
|
||||
count++;
|
||||
}
|
||||
|
|
@ -688,7 +688,7 @@ namespace Server.Network
|
|||
if (Connection != null && _nextActivityCheck - curTicks < 0)
|
||||
{
|
||||
WriteConsole("Disconnecting due to inactivity...");
|
||||
Dispose();
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -715,7 +715,7 @@ namespace Server.Network
|
|||
packetID != 0x91 && packetID != 0xA4 && packetID != 0xEF)
|
||||
{
|
||||
WriteConsole("Encrypted client detected, disconnecting");
|
||||
Dispose();
|
||||
Disconnect();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -744,7 +744,7 @@ namespace Server.Network
|
|||
Console.WriteLine(ex);
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
public void Disconnect()
|
||||
{
|
||||
if (Connection == null || !_running)
|
||||
{
|
||||
|
|
@ -774,7 +774,7 @@ namespace Server.Network
|
|||
Disposed.Enqueue(this);
|
||||
}
|
||||
|
||||
private void Disconnect()
|
||||
private void Dispose()
|
||||
{
|
||||
Connection = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ namespace Server.Network
|
|||
|
||||
if (info == null || a == null || cityIndex < 0 || cityIndex >= info.Length)
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -197,7 +197,7 @@ namespace Server.Network
|
|||
else
|
||||
{
|
||||
state.BlockAllPackets = false;
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ namespace Server.Network
|
|||
|
||||
if (a == null || charSlot < 0 || charSlot >= a.Length)
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -277,11 +277,11 @@ namespace Server.Network
|
|||
|
||||
if (m == null)
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
m.NetState?.Dispose();
|
||||
m.NetState?.Disconnect();
|
||||
|
||||
state.SendClientVersionRequest();
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ namespace Server.Network
|
|||
{
|
||||
if (state.SentFirstPacket)
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ namespace Server.Network
|
|||
)
|
||||
{
|
||||
state.WriteConsole("Invalid client detected, disconnecting");
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -424,7 +424,7 @@ namespace Server.Network
|
|||
}
|
||||
else
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -436,7 +436,7 @@ namespace Server.Network
|
|||
|
||||
if (info == null || a == null || index < 0 || index >= info.Length)
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -457,7 +457,7 @@ namespace Server.Network
|
|||
if (state._seed == 0)
|
||||
{
|
||||
state.WriteConsole("Invalid client detected, disconnecting");
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ namespace Server.Network
|
|||
{
|
||||
if (state.SentFirstPacket)
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -512,7 +512,7 @@ namespace Server.Network
|
|||
private static void AccountLogin_ReplyRej(this NetState state, ALRReason reason)
|
||||
{
|
||||
state.SendAccountLoginRejected(reason);
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
|
||||
private class LoginTimer : Timer
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ namespace Server.Network
|
|||
);
|
||||
}
|
||||
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ namespace Server.Network
|
|||
if (!buttonExists)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ namespace Server.Network
|
|||
if (switchCount < 0 || switchCount > gump.m_Switches)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ namespace Server.Network
|
|||
if (textCount < 0 || textCount > gump.m_TextEntries)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -411,7 +411,7 @@ namespace Server.Network
|
|||
if (textLength > 239)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -596,11 +596,11 @@ namespace Server.Network
|
|||
"Sent ingame packet (0xD7x{0:X2}) before having been attached to a mobile",
|
||||
packetId
|
||||
);
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
else if (ph.Ingame && state.Mobile.Deleted)
|
||||
{
|
||||
state.Dispose();
|
||||
state.Disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue