diff --git a/Continuity.sln b/Continuity.sln index 86836c8..a8a1984 100644 --- a/Continuity.sln +++ b/Continuity.sln @@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{7D560FA1-A61C-4B67-8300-835CA5814621}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wonderking", "Wonderking\Wonderking.csproj", "{6B53A10B-C397-4347-BB00-A12272D0528E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,9 @@ Global {7D560FA1-A61C-4B67-8300-835CA5814621}.Debug|Any CPU.Build.0 = Debug|Any CPU {7D560FA1-A61C-4B67-8300-835CA5814621}.Release|Any CPU.ActiveCfg = Release|Any CPU {7D560FA1-A61C-4B67-8300-835CA5814621}.Release|Any CPU.Build.0 = Release|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Server/AuthSession.cs b/Server/AuthSession.cs index df1dd71..443d3ae 100644 --- a/Server/AuthSession.cs +++ b/Server/AuthSession.cs @@ -1,3 +1,5 @@ +using Wonderking.Packets; + namespace Server; using System.Reflection; diff --git a/Server/LoggerMessages/PacketLoggerMessages.cs b/Server/LoggerMessages/PacketLoggerMessages.cs index 0654492..3601281 100644 --- a/Server/LoggerMessages/PacketLoggerMessages.cs +++ b/Server/LoggerMessages/PacketLoggerMessages.cs @@ -1,8 +1,8 @@ -namespace Server; - using JetBrains.Annotations; using Microsoft.Extensions.Logging; -using Packets; +using Wonderking.Packets; + +namespace Server.LoggerMessages; public static partial class PacketLoggerMessages { diff --git a/Server/PacketHandlers/ChannelSelectionHandler.cs b/Server/PacketHandlers/ChannelSelectionHandler.cs index 3db2358..dbba883 100644 --- a/Server/PacketHandlers/ChannelSelectionHandler.cs +++ b/Server/PacketHandlers/ChannelSelectionHandler.cs @@ -1,10 +1,11 @@ +using Wonderking.Packets.Incoming; + namespace Server.PacketHandlers; using DB; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NetCoreServer; -using Packets.Incoming; public class ChannelSelectionHandler : IPacketHandler { diff --git a/Server/PacketHandlers/IPacketHandler.cs b/Server/PacketHandlers/IPacketHandler.cs index a9f1c86..40448d6 100644 --- a/Server/PacketHandlers/IPacketHandler.cs +++ b/Server/PacketHandlers/IPacketHandler.cs @@ -1,8 +1,9 @@ +using Wonderking.Packets; + namespace Server.PacketHandlers; using JetBrains.Annotations; using NetCoreServer; -using Packets; [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)] public interface IPacketHandler where T : IPacket diff --git a/Server/PacketHandlers/LoginHandler.cs b/Server/PacketHandlers/LoginHandler.cs index 3955229..35dd997 100644 --- a/Server/PacketHandlers/LoginHandler.cs +++ b/Server/PacketHandlers/LoginHandler.cs @@ -1,15 +1,16 @@ -namespace Server.PacketHandlers; - using System.Security.Cryptography; using System.Text; +using Wonderking.Packets.Incoming; +using Wonderking.Packets.Outgoing; + +namespace Server.PacketHandlers; + using DB; using DB.Documents; using Konscious.Security.Cryptography; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NetCoreServer; -using Packets.Incoming; -using Packets.Outgoing; public class LoginHandler : IPacketHandler { @@ -78,12 +79,9 @@ public class LoginHandler : IPacketHandler IsGameMaster = true }; var sess = session as AuthSession; - if (account != null) + if (account != null && sess != null) { - if (sess != null) - { - sess.AccountId = account.Id; - } + sess.AccountId = account.Id; } sess?.Send(loginResponsePacket); diff --git a/Server/Packets/RawPacket.cs b/Server/Packets/RawPacket.cs index 6f96690..11e7ca0 100644 --- a/Server/Packets/RawPacket.cs +++ b/Server/Packets/RawPacket.cs @@ -1,3 +1,5 @@ +using Wonderking.Packets; + namespace Server.Packets; using MassTransit; diff --git a/Server/Server.csproj b/Server/Server.csproj index bd69f41..50ba8a3 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -29,6 +29,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -68,4 +69,8 @@ Always + + + + diff --git a/Server/Services/PacketDistributorService.cs b/Server/Services/PacketDistributorService.cs index 28cbae4..24d0e7d 100644 --- a/Server/Services/PacketDistributorService.cs +++ b/Server/Services/PacketDistributorService.cs @@ -1,3 +1,6 @@ +using Server.LoggerMessages; +using Wonderking.Packets; + namespace Server.Services; using System.Collections.Concurrent; @@ -86,7 +89,7 @@ public class PacketDistributorService : IHostedService return packetsWithId; } - this._logger.NoPacketsFound(); + LoggerMessages.PacketLoggerMessages.NoPacketsFound(this._logger); throw new IncompleteInitialization(); } @@ -106,7 +109,7 @@ public class PacketDistributorService : IHostedService return packetHandlersWithId; } - this._logger.NoPacketHandlersFound(); + LoggerMessages.PacketLoggerMessages.NoPacketHandlersFound(this._logger); throw new IncompleteInitialization(); } @@ -135,8 +138,9 @@ public class PacketDistributorService : IHostedService } var packet = value(item.MessageBody); - this._logger.PacketData(JsonConvert.SerializeObject(packet)); - this._packetHandlersInstantiation[item.OperationCode].GetType().GetMethod(nameof(IPacketHandler.HandleAsync)) + LoggerMessages.PacketLoggerMessages.PacketData(this._logger, JsonConvert.SerializeObject(packet)); + this._packetHandlersInstantiation[item.OperationCode].GetType() + .GetMethod(nameof(IPacketHandler.HandleAsync)) ?.Invoke(this._packetHandlersInstantiation[item.OperationCode], new object[] { packet, item.Session }); this._logger.PacketFinished(item.Session.Id, item.OperationCode); diff --git a/Server/Packets/IPacket.cs b/Wonderking/Packets/IPacket.cs similarity index 86% rename from Server/Packets/IPacket.cs rename to Wonderking/Packets/IPacket.cs index e5d5317..fa795eb 100644 --- a/Server/Packets/IPacket.cs +++ b/Wonderking/Packets/IPacket.cs @@ -1,7 +1,7 @@ -namespace Server.Packets; - using JetBrains.Annotations; +namespace Wonderking.Packets; + [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)] public interface IPacket { diff --git a/Server/Packets/Incoming/ChannelSelectionPacket.cs b/Wonderking/Packets/Incoming/ChannelSelectionPacket.cs similarity index 91% rename from Server/Packets/Incoming/ChannelSelectionPacket.cs rename to Wonderking/Packets/Incoming/ChannelSelectionPacket.cs index ea17fb4..d5db962 100644 --- a/Server/Packets/Incoming/ChannelSelectionPacket.cs +++ b/Wonderking/Packets/Incoming/ChannelSelectionPacket.cs @@ -1,4 +1,4 @@ -namespace Server.Packets.Incoming; +namespace Wonderking.Packets.Incoming; [PacketId(OperationCode.ChannelSelection)] public class ChannelSelectionPacket : IPacket diff --git a/Server/Packets/Incoming/LoginInfoPacket.cs b/Wonderking/Packets/Incoming/LoginInfoPacket.cs similarity index 96% rename from Server/Packets/Incoming/LoginInfoPacket.cs rename to Wonderking/Packets/Incoming/LoginInfoPacket.cs index 4351884..4758ef7 100644 --- a/Server/Packets/Incoming/LoginInfoPacket.cs +++ b/Wonderking/Packets/Incoming/LoginInfoPacket.cs @@ -1,7 +1,7 @@ -namespace Server.Packets.Incoming; - using System.Text; +namespace Wonderking.Packets.Incoming; + [PacketId(OperationCode.LoginInfo)] public class LoginInfoPacket : IPacket { diff --git a/Server/Packets/OperationCode.cs b/Wonderking/Packets/OperationCode.cs similarity index 77% rename from Server/Packets/OperationCode.cs rename to Wonderking/Packets/OperationCode.cs index 578c544..f8b9eea 100644 --- a/Server/Packets/OperationCode.cs +++ b/Wonderking/Packets/OperationCode.cs @@ -1,4 +1,4 @@ -namespace Server.Packets; +namespace Wonderking.Packets; public enum OperationCode : ushort { diff --git a/Server/Packets/Outgoing/LoginResponsePacket.cs b/Wonderking/Packets/Outgoing/LoginResponsePacket.cs similarity index 98% rename from Server/Packets/Outgoing/LoginResponsePacket.cs rename to Wonderking/Packets/Outgoing/LoginResponsePacket.cs index 63299fe..057d032 100644 --- a/Server/Packets/Outgoing/LoginResponsePacket.cs +++ b/Wonderking/Packets/Outgoing/LoginResponsePacket.cs @@ -1,4 +1,4 @@ -namespace Server.Packets.Outgoing; +namespace Wonderking.Packets.Outgoing; [PacketId(OperationCode.LoginResponse)] public class LoginResponsePacket : IPacket diff --git a/Server/Packets/Outgoing/LoginResponseReason.cs b/Wonderking/Packets/Outgoing/LoginResponseReason.cs similarity index 92% rename from Server/Packets/Outgoing/LoginResponseReason.cs rename to Wonderking/Packets/Outgoing/LoginResponseReason.cs index b4e8bff..adc830f 100644 --- a/Server/Packets/Outgoing/LoginResponseReason.cs +++ b/Wonderking/Packets/Outgoing/LoginResponseReason.cs @@ -1,4 +1,4 @@ -namespace Server.Packets.Outgoing; +namespace Wonderking.Packets.Outgoing; public enum LoginResponseReason : byte { diff --git a/Server/Packets/Outgoing/ServerChannelData.cs b/Wonderking/Packets/Outgoing/ServerChannelData.cs similarity index 80% rename from Server/Packets/Outgoing/ServerChannelData.cs rename to Wonderking/Packets/Outgoing/ServerChannelData.cs index a6eee00..a2800ed 100644 --- a/Server/Packets/Outgoing/ServerChannelData.cs +++ b/Wonderking/Packets/Outgoing/ServerChannelData.cs @@ -1,4 +1,4 @@ -namespace Server.Packets.Outgoing; +namespace Wonderking.Packets.Outgoing; public struct ServerChannelData { diff --git a/Server/Packets/PacketIdAttribute.cs b/Wonderking/Packets/PacketIdAttribute.cs similarity index 87% rename from Server/Packets/PacketIdAttribute.cs rename to Wonderking/Packets/PacketIdAttribute.cs index 6638733..e2f2b5a 100644 --- a/Server/Packets/PacketIdAttribute.cs +++ b/Wonderking/Packets/PacketIdAttribute.cs @@ -1,4 +1,4 @@ -namespace Server.Packets; +namespace Wonderking.Packets; [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class PacketIdAttribute : Attribute diff --git a/Wonderking/Wonderking.csproj b/Wonderking/Wonderking.csproj new file mode 100644 index 0000000..a2cdaa6 --- /dev/null +++ b/Wonderking/Wonderking.csproj @@ -0,0 +1,13 @@ + + + + enable + enable + net8.0;net7.0 + + + + + + +