Fixes #258 & remove redundant dispose code
This commit is contained in:
parent
05a6b10e21
commit
a68c7a0ba3
@ -70,7 +70,7 @@ namespace TrueCraft
|
|||||||
public ItemStack ItemStaging { get; set; }
|
public ItemStack ItemStaging { get; set; }
|
||||||
public IWindow CurrentWindow { get; internal set; }
|
public IWindow CurrentWindow { get; internal set; }
|
||||||
public bool EnableLogging { get; set; }
|
public bool EnableLogging { get; set; }
|
||||||
public IPacket LastSuccessfulPacket { get; set; }
|
//public IPacket LastSuccessfulPacket { get; set; }
|
||||||
public DateTime ExpectedDigComplete { get; set; }
|
public DateTime ExpectedDigComplete { get; set; }
|
||||||
|
|
||||||
public Socket Connection { get; private set; }
|
public Socket Connection { get; private set; }
|
||||||
@ -329,10 +329,11 @@ namespace TrueCraft
|
|||||||
}
|
}
|
||||||
|
|
||||||
var packets = PacketReader.ReadPackets(this, e.Buffer, e.Offset, e.BytesTransferred);
|
var packets = PacketReader.ReadPackets(this, e.Buffer, e.Offset, e.BytesTransferred);
|
||||||
|
try
|
||||||
|
{
|
||||||
foreach (IPacket packet in packets)
|
foreach (IPacket packet in packets)
|
||||||
{
|
{
|
||||||
LastSuccessfulPacket = packet;
|
//LastSuccessfulPacket = packet;
|
||||||
|
|
||||||
if (PacketHandlers[packet.ID] != null)
|
if (PacketHandlers[packet.ID] != null)
|
||||||
{
|
{
|
||||||
@ -357,6 +358,15 @@ namespace TrueCraft
|
|||||||
Log("Unhandled packet {0}", packet.GetType().Name);
|
Log("Unhandled packet {0}", packet.GetType().Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (NotSupportedException)
|
||||||
|
{
|
||||||
|
// Usually thrown when we do not have the requested packet definition/type.
|
||||||
|
|
||||||
|
// Might want to create its own Exception type for being more specific.
|
||||||
|
Server.Log(LogCategory.Debug, "Disconnecting client due to unsupported packet received.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (sem != null)
|
if (sem != null)
|
||||||
sem.Release();
|
sem.Release();
|
||||||
@ -547,8 +557,6 @@ namespace TrueCraft
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
@ -565,14 +573,8 @@ namespace TrueCraft
|
|||||||
|
|
||||||
if (Disposed != null)
|
if (Disposed != null)
|
||||||
Disposed(this, null);
|
Disposed(this, null);
|
||||||
}
|
|
||||||
|
|
||||||
sem = null;
|
sem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
~RemoteClient()
|
|
||||||
{
|
|
||||||
Dispose(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user