forked from PGR/ascnet
1
0
Fork 0

more sdk routes(still soflocks), and added gameserver response logger

This commit is contained in:
rfi 2023-10-15 12:43:20 +07:00
parent f5ef33f16a
commit b9b4796d0e
4 changed files with 203 additions and 5 deletions

View File

@ -133,7 +133,7 @@ namespace AscNet.GameServer
DisconnectProtocol();
}
public void SendPush<T>(T push)
public void SendPush<T>(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>(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)

View File

@ -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<dynamic>(),
AppearanceDay = Array.Empty<dynamic>(),
AppearanceTime = Array.Empty<dynamic>(),
DisappearanceCondition = Array.Empty<dynamic>(),
}
}
};
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<GameNotice> 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;

View File

@ -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; }
}
}
}

View File

@ -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; }
}
}
}