From 2dd46d8d8efb6acd0e0e0301493b257d8e0fed87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 22 Jan 2022 18:07:18 +0100 Subject: [PATCH] feat(samples): add default packets --- Samples/InterceptNameChanger/NameChanger.cs | 10 ++++++++++ Samples/SimpleChat/SimpleChat.cs | 10 ++++++++++ Samples/WalkCommands/Startup.cs | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/Samples/InterceptNameChanger/NameChanger.cs b/Samples/InterceptNameChanger/NameChanger.cs index 75653b6..14780cb 100644 --- a/Samples/InterceptNameChanger/NameChanger.cs +++ b/Samples/InterceptNameChanger/NameChanger.cs @@ -14,6 +14,8 @@ using NosSmooth.LocalClient; using NosSmooth.LocalClient.Extensions; using NosSmooth.Packets.Enums; using NosSmooth.Packets.Enums.Chat; +using NosSmooth.Packets.Extensions; +using NosSmooth.Packets.Packets; using NosSmooth.Packets.Server.Chat; namespace InterceptNameChanger @@ -57,6 +59,14 @@ namespace InterceptNameChanger logger.LogResultError(initializeResult); } + var packetTypesRepository = provider.GetRequiredService(); + var packetAddResult = packetTypesRepository.AddDefaultPackets(); + if (!packetAddResult.IsSuccess) + { + logger.LogError("Could not initialize default packet serializers correctly"); + logger.LogResultError(packetAddResult); + } + var client = provider.GetRequiredService(); var sayResult = await client.ReceivePacketAsync diff --git a/Samples/SimpleChat/SimpleChat.cs b/Samples/SimpleChat/SimpleChat.cs index 928de73..72d95c7 100644 --- a/Samples/SimpleChat/SimpleChat.cs +++ b/Samples/SimpleChat/SimpleChat.cs @@ -12,6 +12,8 @@ using NosSmooth.LocalBinding; using NosSmooth.LocalClient.Extensions; using NosSmooth.Packets.Enums; using NosSmooth.Packets.Enums.Chat; +using NosSmooth.Packets.Extensions; +using NosSmooth.Packets.Packets; using NosSmooth.Packets.Server.Chat; namespace SimpleChat; @@ -52,6 +54,14 @@ public class SimpleChat logger.LogResultError(initializeResult); } + var packetTypesRepository = provider.GetRequiredService(); + var packetAddResult = packetTypesRepository.AddDefaultPackets(); + if (!packetAddResult.IsSuccess) + { + logger.LogError("Could not initialize default packet serializers correctly"); + logger.LogResultError(packetAddResult); + } + var client = provider.GetRequiredService(); await client.ReceivePacketAsync diff --git a/Samples/WalkCommands/Startup.cs b/Samples/WalkCommands/Startup.cs index be813ae..ca39e72 100644 --- a/Samples/WalkCommands/Startup.cs +++ b/Samples/WalkCommands/Startup.cs @@ -12,6 +12,8 @@ using NosSmooth.Core.Extensions; using NosSmooth.LocalBinding; using NosSmooth.LocalClient; using NosSmooth.LocalClient.Extensions; +using NosSmooth.Packets.Extensions; +using NosSmooth.Packets.Packets; using Remora.Commands.Extensions; using WalkCommands.Commands; @@ -64,6 +66,14 @@ public class Startup logger.LogResultError(initializeResult); } + var packetTypesRepository = provider.GetRequiredService(); + var packetAddResult = packetTypesRepository.AddDefaultPackets(); + if (!packetAddResult.IsSuccess) + { + logger.LogError("Could not initialize default packet serializers correctly"); + logger.LogResultError(packetAddResult); + } + var mainCancellation = provider.GetRequiredService(); var client = provider.GetRequiredService(); -- 2.49.0