From a6b804dfe756ad76fe9884c98ac062ac0fbbeec0 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Thu, 12 Oct 2023 09:05:42 +0200 Subject: [PATCH] chore: pre-commit test commit --- Server/AuthSession.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Server/AuthSession.cs b/Server/AuthSession.cs index 44b93e3..7b0d1cd 100644 --- a/Server/AuthSession.cs +++ b/Server/AuthSession.cs @@ -1,4 +1,4 @@ -namespace Server; +namespace Server; using System.Reflection; using MassTransit.Mediator; @@ -43,7 +43,7 @@ public class AuthSession : TcpSession Span buffer = stackalloc byte[length]; buffer.Clear(); - packetData.CopyTo(buffer.Slice(8, length - 8)); + packetData.CopyTo(buffer[8..length]); var bytesOfLength = BitConverter.GetBytes(length); var bytesOfOpcode = BitConverter.GetBytes((ushort)opcode); @@ -71,11 +71,15 @@ public class AuthSession : TcpSession // xor every value after the first 8 bytes var dataBuffer = Decrypt(new ArraySegment(buffer, 8, (int)size - 8).ToArray()); - this.logger.LogDebug("Length {length}", BitConverter.ToUInt16(buffer, 0)); + this.logger.LogDebug("Length {Length}", BitConverter.ToUInt16(buffer, 0)); + var opCode = BitConverter.ToUInt16(buffer.ToArray(), 2); + this.logger.LogDebug("Packet Op Code: {OpCode}", opCode); this.logger.LogDebug("Some Value: {RandomValue}", buffer[4]); + var clientAliveTime = BitConverter.ToUInt16(buffer.ToArray(), 5); + this.logger.LogDebug("Client Alive time: {ClientAliveTime}", clientAliveTime); this.logger.LogDebug("Might be a flag: {Flag}", buffer[7]); @@ -83,7 +87,10 @@ public class AuthSession : TcpSession var rawPacket = new RawPacket((OperationCode)opCode, dataBuffer, clientAliveTime, buffer[7], buffer[4], this.Id, this); - Task.Run(() => this.mediator.Send(rawPacket)); + + var thread = new Thread(() => this.mediator.Send(rawPacket).Start()) { IsBackground = true }; + thread.Start(); + this.logger.LogInformation("Connection from: {@RemoteEndpoint}", this.Socket.RemoteEndPoint?.ToString()); base.OnReceived(decryptedBuffer.ToArray(), offset, decryptedBuffer.Length); }