chore: pre-commit test commit

This commit is contained in:
Timothy Schenk 2023-10-12 09:05:42 +02:00
parent 659e75d2df
commit a6b804dfe7

View file

@ -1,4 +1,4 @@
namespace Server;
namespace Server;
using System.Reflection;
using MassTransit.Mediator;
@ -43,7 +43,7 @@ public class AuthSession : TcpSession
Span<byte> 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<byte>(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);
}