From f26c11ac73fcb06ab0c07fcc54d9d63a3dae82bc Mon Sep 17 00:00:00 2001 From: Longfeng Qin Date: Wed, 11 Dec 2024 04:49:09 +0800 Subject: [PATCH] 31-TitleHandler --- Server/Program.cs | 3 +++ .../31-TitleHandler/31-01-NewTitlesRequest.cs | 16 ++++++++++++++ .../31-TitleHandler/31-03-TitleListRequest.cs | 16 ++++++++++++++ .../31-06-TitleConditionRequest.cs | 22 +++++++++++++++++++ .../31-08-PlayAchievementsRequest.cs | 16 ++++++++++++++ .../31-0A-ReceiveTitleRewardRequest.cs | 22 +++++++++++++++++++ Server/QueryServer.cs | 2 +- Server/Server.cs | 6 +++-- Server/Server.csproj | 7 +++++- 9 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 Server/Protocol/Handlers/31-TitleHandler/31-01-NewTitlesRequest.cs create mode 100644 Server/Protocol/Handlers/31-TitleHandler/31-03-TitleListRequest.cs create mode 100644 Server/Protocol/Handlers/31-TitleHandler/31-06-TitleConditionRequest.cs create mode 100644 Server/Protocol/Handlers/31-TitleHandler/31-08-PlayAchievementsRequest.cs create mode 100644 Server/Protocol/Handlers/31-TitleHandler/31-0A-ReceiveTitleRewardRequest.cs diff --git a/Server/Program.cs b/Server/Program.cs index d1f8ace..adb299a 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -43,6 +43,9 @@ namespace PSO2SERVER public const int ServerShipListProtNums_NA = 6; public const int ServerShipListProt_NA = 13001; + public const string ServerBlockBalanceName = "Test"; + public const int ServerBlockBalanceProt = 12205; + public const string ServerSettingsKey = "Resources\\settings.txt"; public const string ServerMemoryPacket = "Resources\\setMemoryPacket.bin"; //TODO diff --git a/Server/Protocol/Handlers/31-TitleHandler/31-01-NewTitlesRequest.cs b/Server/Protocol/Handlers/31-TitleHandler/31-01-NewTitlesRequest.cs new file mode 100644 index 0000000..b872735 --- /dev/null +++ b/Server/Protocol/Handlers/31-TitleHandler/31-01-NewTitlesRequest.cs @@ -0,0 +1,16 @@ +using System; +using PSO2SERVER.Models; +using PSO2SERVER.Protocol.Packets; + +namespace PSO2SERVER.Protocol.Handlers +{ + [PacketHandlerAttr(0x31, 0x01)] + public class NewTitlesRequest : PacketHandler + { + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length); + Logger.WriteHex(info, data); + } + } +} diff --git a/Server/Protocol/Handlers/31-TitleHandler/31-03-TitleListRequest.cs b/Server/Protocol/Handlers/31-TitleHandler/31-03-TitleListRequest.cs new file mode 100644 index 0000000..f4ddbb4 --- /dev/null +++ b/Server/Protocol/Handlers/31-TitleHandler/31-03-TitleListRequest.cs @@ -0,0 +1,16 @@ +using System; +using PSO2SERVER.Models; +using PSO2SERVER.Protocol.Packets; + +namespace PSO2SERVER.Protocol.Handlers +{ + [PacketHandlerAttr(0x31, 0x03)] + public class TitleListRequest : PacketHandler + { + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length); + Logger.WriteHex(info, data); + } + } +} diff --git a/Server/Protocol/Handlers/31-TitleHandler/31-06-TitleConditionRequest.cs b/Server/Protocol/Handlers/31-TitleHandler/31-06-TitleConditionRequest.cs new file mode 100644 index 0000000..25fb12b --- /dev/null +++ b/Server/Protocol/Handlers/31-TitleHandler/31-06-TitleConditionRequest.cs @@ -0,0 +1,22 @@ +using System; +using PSO2SERVER.Models; +using PSO2SERVER.Protocol.Packets; + +namespace PSO2SERVER.Protocol.Handlers +{ + [PacketHandlerAttr(0x31, 0x06)] + public class TitleConditionRequest : PacketHandler + { + public struct GetTitleConditionPacket + { + /// Requested title ID. + public uint title_id; + } + + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length); + Logger.WriteHex(info, data); + } + } +} diff --git a/Server/Protocol/Handlers/31-TitleHandler/31-08-PlayAchievementsRequest.cs b/Server/Protocol/Handlers/31-TitleHandler/31-08-PlayAchievementsRequest.cs new file mode 100644 index 0000000..7bac797 --- /dev/null +++ b/Server/Protocol/Handlers/31-TitleHandler/31-08-PlayAchievementsRequest.cs @@ -0,0 +1,16 @@ +using System; +using PSO2SERVER.Models; +using PSO2SERVER.Protocol.Packets; + +namespace PSO2SERVER.Protocol.Handlers +{ + [PacketHandlerAttr(0x31, 0x08)] + public class PlayAchievementsRequest : PacketHandler + { + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length); + Logger.WriteHex(info, data); + } + } +} diff --git a/Server/Protocol/Handlers/31-TitleHandler/31-0A-ReceiveTitleRewardRequest.cs b/Server/Protocol/Handlers/31-TitleHandler/31-0A-ReceiveTitleRewardRequest.cs new file mode 100644 index 0000000..9be22e8 --- /dev/null +++ b/Server/Protocol/Handlers/31-TitleHandler/31-0A-ReceiveTitleRewardRequest.cs @@ -0,0 +1,22 @@ +using System; +using PSO2SERVER.Models; +using PSO2SERVER.Protocol.Packets; + +namespace PSO2SERVER.Protocol.Handlers +{ + [PacketHandlerAttr(0x31, 0x0A)] + public class ReceiveTitleRewardRequest : PacketHandler + { + public struct ReceiveTitleRewardRequestPacket + { + /// Requested title ID. + public uint title_id; + } + + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length); + Logger.WriteHex(info, data); + } + } +} diff --git a/Server/QueryServer.cs b/Server/QueryServer.cs index c6fd36b..c3f276a 100644 --- a/Server/QueryServer.cs +++ b/Server/QueryServer.cs @@ -106,7 +106,7 @@ namespace PSO2SERVER private async Task DoBlockBalanceAsync(Socket socket) { - var balancepacket = new BlockBalancePacket("test", 12205).GetPacketBytes(); + var balancepacket = new BlockBalancePacket(ServerApp.ServerBlockBalanceName, ServerApp.ServerBlockBalanceProt).GetPacketBytes(); await Task.Factory.FromAsync( (cb, state) => socket.BeginSend(balancepacket, 0, balancepacket.Length, SocketFlags.None, cb, state), diff --git a/Server/Server.cs b/Server/Server.cs index e026ba3..de4ac3e 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -11,8 +11,9 @@ namespace PSO2SERVER { public static Server Instance { get; private set; } - private readonly SocketServer _server; + public string _name { get; private set; } + private readonly SocketServer _server; public List Clients { get; private set; } public DateTime StartTime { get; private set; } public Timer PingTimer; @@ -20,7 +21,8 @@ namespace PSO2SERVER public Server() { Clients = new List(); - _server = new SocketServer(12205); + _name = ServerApp.ServerBlockBalanceName; + _server = new SocketServer(ServerApp.ServerBlockBalanceProt); _server.NewClient += HandleNewClient; Instance = this; StartTime = DateTime.Now; diff --git a/Server/Server.csproj b/Server/Server.csproj index 6447754..1a87ed7 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -410,9 +410,14 @@ + + + + + - +