#pragma warning disable AsyncFixer01 // Unnecessary async/await usage /// <inheritdoc /> public override async Task HandleMessage(IProxiedMessageContext <GamePacketPayload, GamePacketPayload> context, GamePacketPayload payload) { if (Logger.IsWarnEnabled) { Logger.Warn($"Recieved unproxied Payload: {payload.GetType().Name} on {this.GetType().Name}"); } if (payload is UnknownGamePayload) { return; } //Since we're connected to a vanilla realm we, at least for now, want to discard unknown opcode payloads //above CMSG_ACCEPT_LEVEL_GRANT if ((short)payload.GetOperationCode() > 0x41F || OpCodeBlackList.Contains(payload.GetOperationCode())) { if (Logger.IsWarnEnabled) { Logger.Warn($"Discarding based on OpCode: {payload.GetOperationCode()} from client."); } return; } //Forward to the server await context.ProxyConnection.SendMessage(payload) .ConfigureAwait(false); }
public void Can_Serialize_DeserializedDTO_To_Same_Binary_Representation(PacketCaptureTestEntry entry) { //arrange Console.WriteLine($"Entry Size: {entry.BinaryData.Length} OpCode: {entry.OpCode}"); SerializerService serializer = Serializer; GamePacketPayload payload = serializer.Deserialize <GamePacketPayload>(entry.BinaryData); //act byte[] serializedBytes = serializer.Serialize(payload); //assert try { Assert.AreEqual(entry.BinaryData.Length, serializedBytes.Length, $"Mismatched length on OpCode: {entry.OpCode} Type: {payload.GetType().Name}"); } catch (AssertionException e) { Assert.Fail($"Failed: {e.Message} {PrintFailureBytes(entry.BinaryData, serializedBytes)}"); } for (int i = 0; i < entry.BinaryData.Length; i++) { Assert.AreEqual(entry.BinaryData[i], serializedBytes[i], $"Mismatched byte value at Index: {i} on OpCode: {entry.OpCode} Type: {payload.GetType().Name}"); } }
public void Can_Serialize_DeserializedDTO_To_Same_Binary_Representation(PacketCaptureTestEntry entry) { //arrange Console.WriteLine($"Entry Size: {entry.BinaryData.Length} OpCode: {entry.OpCode}"); SerializerService serializer = Serializer; GamePacketPayload payload = serializer.Read <GamePacketPayload>(new Span <byte>(entry.BinaryData), 0); //act int offset = 0; Span <byte> buffer = new Span <byte>(new byte[62000]); try { serializer.Write(payload, buffer, ref offset); } catch (KnownIncompleteSerializationException e) { Assert.Warn($"Incomplete serialization implementation for Type: {e.Message}. Message: {e}"); return; } //assert try { Assert.AreEqual(entry.BinaryData.Length, offset, $"Mismatched length on OpCode: {entry.OpCode} Type: {payload.GetType().Name}"); } catch (AssertionException e) { Assert.Fail($"Failed: {e.Message} {PrintFailureBytes(entry.BinaryData, buffer.Slice(0, offset).ToArray())}"); } for (int i = 0; i < entry.BinaryData.Length; i++) { Assert.AreEqual(entry.BinaryData[i], buffer[i], $"Mismatched byte value at Index: {i} on OpCode: {entry.OpCode} Type: {payload.GetType().Name}"); } }