Seperate out the NetworkPacketDictonary
This commit is contained in:
1 parent
531fd2572f
commit
3992c3debc
6 files changed
+48
-46
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Mistox.Attributes;
|
||||
|
||||
namespace Mistox.Server {
|
||||
public class TCPConnection : IDisposable {
|
||||
@@ -41,13 +42,8 @@ namespace Mistox.Server {
|
||||
// Read off the data
|
||||
await ns.ReadExactlyAsync(payloadBuffer, 0, dataLength);
|
||||
|
||||
// Get the type from the tag
|
||||
if (!DataPacket.ServerToClientPackets.TryGetValue(packetbyte, out Type resolvedType)) {
|
||||
throw new Exception($"Unknown packet type ID: {packetbyte}");
|
||||
}
|
||||
|
||||
// Create the dataobject
|
||||
dynamic dataobject = DataPacket.Deserialize( resolvedType, dataLength, payloadBuffer.AsMemory(DataPacket.HeaderLength, dataLength) );
|
||||
dynamic dataobject = DataPacket.Deserialize( packetbyte, dataLength, payloadBuffer.AsMemory(DataPacket.HeaderLength, dataLength) );
|
||||
|
||||
// Return the object
|
||||
ServerInterface.ServerInstance.InvokeDataReceived(dataobject);
|
||||
|
||||
Reference in new issue
Block a user