From b9b4796d0e16e5d547f04b4bbc7823e506e96add Mon Sep 17 00:00:00 2001 From: rfi Date: Sun, 15 Oct 2023 12:43:20 +0700 Subject: [PATCH] more sdk routes(still soflocks), and added gameserver response logger --- AscNet.GameServer/Session.cs | 8 +- .../Controllers/ConfigController.cs | 64 +++++++++++++- AscNet.SDKServer/Models/GameNotice.cs | 50 +++++++++++ AscNet.SDKServer/Models/ScrollNotice.cs | 86 +++++++++++++++++++ 4 files changed, 203 insertions(+), 5 deletions(-) create mode 100644 AscNet.SDKServer/Models/GameNotice.cs create mode 100644 AscNet.SDKServer/Models/ScrollNotice.cs diff --git a/AscNet.GameServer/Session.cs b/AscNet.GameServer/Session.cs index 22a4f4c..0ad7c80 100644 --- a/AscNet.GameServer/Session.cs +++ b/AscNet.GameServer/Session.cs @@ -133,7 +133,7 @@ namespace AscNet.GameServer DisconnectProtocol(); } - public void SendPush(T push) + public void SendPush(T push) where T : new() { Packet.Push packet = new() { @@ -146,7 +146,7 @@ namespace AscNet.GameServer Type = Packet.ContentType.Push, Content = MessagePackSerializer.Serialize(packet) }); - log.Info(packet.Name); + log.Info($"{packet.Name}{(Common.Common.config.VerboseLevel >= VerboseLevel.Debug ? (", " + JsonConvert.SerializeObject(push)) : "")}"); } public void SendPush(string name, byte[] push) @@ -162,7 +162,7 @@ namespace AscNet.GameServer Type = Packet.ContentType.Push, Content = MessagePackSerializer.Serialize(packet) }); - log.Info(packet.Name); + log.Info($"{name}{(Common.Common.config.VerboseLevel >= VerboseLevel.Debug ? (", " + JsonConvert.SerializeObject(MessagePackSerializer.Typeless.Deserialize(push))) : "")}"); } public void SendResponse(T response, int clientSeq = 0) where T : new() @@ -179,7 +179,7 @@ namespace AscNet.GameServer Type = Packet.ContentType.Response, Content = MessagePackSerializer.Serialize(packet) }); - log.Info(packet.Name); + log.Info($"{packet.Name}{(Common.Common.config.VerboseLevel >= VerboseLevel.Debug ? (", " + JsonConvert.SerializeObject(response)) : "")}"); } private void Send(Packet packet) diff --git a/AscNet.SDKServer/Controllers/ConfigController.cs b/AscNet.SDKServer/Controllers/ConfigController.cs index 5baa934..d2c2655 100644 --- a/AscNet.SDKServer/Controllers/ConfigController.cs +++ b/AscNet.SDKServer/Controllers/ConfigController.cs @@ -57,14 +57,75 @@ namespace AscNet.SDKServer.Controllers EndTime = 0, HtmlUrl = "/", Id = "1", - ModifyTime = 0, + ModifyTime = DateTimeOffset.Now.ToUnixTimeSeconds(), Title = "NOTICE" }; + string serializedObject = JsonConvert.SerializeObject(notice); SDKServer.log.Info(serializedObject); return serializedObject; }); + app.MapGet("/prod/client/notice/config/com.kurogame.punishing.grayraven.en.pc/{version}/ScrollTextNotice.json", (HttpContext ctx) => + { + ScrollTextNotice notice = new() + { + Id = "1", + ModifyTime = DateTimeOffset.Now.ToUnixTimeSeconds(), + BeginTime = 0, + EndTime = 0, + Content = "[ANNOUNCEMENT] There is no announcement.", + ScrollInterval = 300, + ScrollTimes = 15, + ShowInFight = 1, + ShowInPhotograph = 1 + }; + + string serializedObject = JsonConvert.SerializeObject(notice); + SDKServer.log.Info(serializedObject); + return serializedObject; + }); + + app.MapGet("/prod/client/notice/config/com.kurogame.punishing.grayraven.en.pc/{version}/ScrollPicNotice.json", (HttpContext ctx) => + { + ScrollPicNotice notice = new() + { + Id = "1", + ModifyTime = DateTimeOffset.Now.ToUnixTimeSeconds(), + Content = new ScrollPicNotice.NoticeContent[] + { + new ScrollPicNotice.NoticeContent() + { + Id = 0, + PicAddr = "0", + JumpType = "0", + JumpAddr = "0", + PicType = "0", + Interval = 5, + BeginTime = DateTimeOffset.Now.ToUnixTimeSeconds(), + EndTime = DateTimeOffset.Now.ToUnixTimeSeconds() + 3600 * 24, + AppearanceCondition = Array.Empty(), + AppearanceDay = Array.Empty(), + AppearanceTime = Array.Empty(), + DisappearanceCondition = Array.Empty(), + } + } + }; + + string serializedObject = JsonConvert.SerializeObject(notice); + SDKServer.log.Info(serializedObject); + return serializedObject; + }); + + app.MapGet("/prod/client/notice/config/com.kurogame.punishing.grayraven.en.pc/{version}/GameNotice.json", (HttpContext ctx) => + { + List notices = new(); + + string serializedObject = JsonConvert.SerializeObject(notices); + SDKServer.log.Info(serializedObject); + return serializedObject; + }); + app.MapPost("/feedback", (HttpContext ctx) => { SDKServer.log.Info("1"); @@ -80,6 +141,7 @@ namespace AscNet.SDKServer.Controllers Port = Common.Common.config.GameServer.Port, Token = token }; + string serializedObject = JsonConvert.SerializeObject(gate); SDKServer.log.Info(serializedObject); return serializedObject; diff --git a/AscNet.SDKServer/Models/GameNotice.cs b/AscNet.SDKServer/Models/GameNotice.cs new file mode 100644 index 0000000..812e1d9 --- /dev/null +++ b/AscNet.SDKServer/Models/GameNotice.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; + +namespace AscNet.SDKServer.Models +{ +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public partial class GameNotice + { + [JsonProperty("Id", NullValueHandling = NullValueHandling.Ignore)] + public string Id { get; set; } + + [JsonProperty("Title", NullValueHandling = NullValueHandling.Ignore)] + public string Title { get; set; } + + [JsonProperty("Tag", NullValueHandling = NullValueHandling.Ignore)] + public long? Tag { get; set; } + + [JsonProperty("Type", NullValueHandling = NullValueHandling.Ignore)] + public long? Type { get; set; } + + [JsonProperty("Order", NullValueHandling = NullValueHandling.Ignore)] + public long? Order { get; set; } + + [JsonProperty("ModifyTime", NullValueHandling = NullValueHandling.Ignore)] + public long? ModifyTime { get; set; } + + [JsonProperty("BeginTime", NullValueHandling = NullValueHandling.Ignore)] + public long? BeginTime { get; set; } + + [JsonProperty("EndTime", NullValueHandling = NullValueHandling.Ignore)] + public long? EndTime { get; set; } + + [JsonProperty("Content", NullValueHandling = NullValueHandling.Ignore)] + public NoticeContent[] Content { get; set; } + + public partial class NoticeContent + { + [JsonProperty("Id", NullValueHandling = NullValueHandling.Ignore)] + public long? Id { get; set; } + + [JsonProperty("Title", NullValueHandling = NullValueHandling.Ignore)] + public string Title { get; set; } + + [JsonProperty("Url", NullValueHandling = NullValueHandling.Ignore)] + public string Url { get; set; } + + [JsonProperty("Order", NullValueHandling = NullValueHandling.Ignore)] + public string Order { get; set; } + } + } +} diff --git a/AscNet.SDKServer/Models/ScrollNotice.cs b/AscNet.SDKServer/Models/ScrollNotice.cs new file mode 100644 index 0000000..cbeb0a1 --- /dev/null +++ b/AscNet.SDKServer/Models/ScrollNotice.cs @@ -0,0 +1,86 @@ +using Newtonsoft.Json; + +namespace AscNet.SDKServer.Models +{ +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public partial class ScrollTextNotice + { + [JsonProperty("Id", NullValueHandling = NullValueHandling.Ignore)] + public string Id { get; set; } + + [JsonProperty("ModifyTime", NullValueHandling = NullValueHandling.Ignore)] + public long? ModifyTime { get; set; } + + [JsonProperty("BeginTime", NullValueHandling = NullValueHandling.Ignore)] + public long? BeginTime { get; set; } + + [JsonProperty("EndTime", NullValueHandling = NullValueHandling.Ignore)] + public long? EndTime { get; set; } + + [JsonProperty("Content", NullValueHandling = NullValueHandling.Ignore)] + public string Content { get; set; } + + [JsonProperty("ScrollInterval", NullValueHandling = NullValueHandling.Ignore)] + public long? ScrollInterval { get; set; } + + [JsonProperty("ScrollTimes", NullValueHandling = NullValueHandling.Ignore)] + public long? ScrollTimes { get; set; } + + [JsonProperty("ShowInFight", NullValueHandling = NullValueHandling.Ignore)] + public long? ShowInFight { get; set; } + + [JsonProperty("ShowInPhotograph", NullValueHandling = NullValueHandling.Ignore)] + public long? ShowInPhotograph { get; set; } + } + + public partial class ScrollPicNotice + { + [JsonProperty("Id", NullValueHandling = NullValueHandling.Ignore)] + public string Id { get; set; } + + [JsonProperty("ModifyTime", NullValueHandling = NullValueHandling.Ignore)] + public long? ModifyTime { get; set; } + + [JsonProperty("Content", NullValueHandling = NullValueHandling.Ignore)] + public NoticeContent[] Content { get; set; } + + public partial class NoticeContent + { + [JsonProperty("Id", NullValueHandling = NullValueHandling.Ignore)] + public long? Id { get; set; } + + [JsonProperty("PicAddr", NullValueHandling = NullValueHandling.Ignore)] + public string PicAddr { get; set; } + + [JsonProperty("JumpType", NullValueHandling = NullValueHandling.Ignore)] + public string JumpType { get; set; } + + [JsonProperty("JumpAddr", NullValueHandling = NullValueHandling.Ignore)] + public string JumpAddr { get; set; } + + [JsonProperty("PicType", NullValueHandling = NullValueHandling.Ignore)] + public string PicType { get; set; } + + [JsonProperty("Interval", NullValueHandling = NullValueHandling.Ignore)] + public long? Interval { get; set; } + + [JsonProperty("BeginTime", NullValueHandling = NullValueHandling.Ignore)] + public long? BeginTime { get; set; } + + [JsonProperty("EndTime", NullValueHandling = NullValueHandling.Ignore)] + public long? EndTime { get; set; } + + [JsonProperty("AppearanceDay", NullValueHandling = NullValueHandling.Ignore)] + public dynamic[] AppearanceDay { get; set; } + + [JsonProperty("AppearanceCondition", NullValueHandling = NullValueHandling.Ignore)] + public dynamic[] AppearanceCondition { get; set; } + + [JsonProperty("DisappearanceCondition", NullValueHandling = NullValueHandling.Ignore)] + public dynamic[] DisappearanceCondition { get; set; } + + [JsonProperty("AppearanceTime", NullValueHandling = NullValueHandling.Ignore)] + public dynamic[] AppearanceTime { get; set; } + } + } +}