2023-10-10 09:56:08 +00:00
|
|
|
|
using AscNet.Common.MsgPack;
|
2023-10-14 16:13:29 +00:00
|
|
|
|
using MessagePack;
|
2023-10-11 13:20:26 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2023-10-10 09:56:08 +00:00
|
|
|
|
|
|
|
|
|
namespace AscNet.GameServer.Handlers
|
|
|
|
|
{
|
|
|
|
|
internal class AccountModule
|
|
|
|
|
{
|
2023-10-14 13:00:56 +00:00
|
|
|
|
[RequestPacketHandler("HandshakeRequest")]
|
|
|
|
|
public static void HandshakeRequestHandler(Session session, Packet.Request packet)
|
2023-10-10 09:56:08 +00:00
|
|
|
|
{
|
2023-10-11 21:15:35 +00:00
|
|
|
|
// TODO: make this somehow universal, look into better architecture to handle packets
|
|
|
|
|
// and automatically log their deserialized form
|
2023-10-14 15:05:58 +00:00
|
|
|
|
|
2023-10-10 09:56:08 +00:00
|
|
|
|
HandshakeResponse response = new()
|
|
|
|
|
{
|
|
|
|
|
Code = 0,
|
|
|
|
|
UtcOpenTime = 0,
|
|
|
|
|
Sha1Table = null
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-14 13:00:56 +00:00
|
|
|
|
session.SendResponse(response, packet.Id);
|
2023-10-10 09:56:08 +00:00
|
|
|
|
}
|
2023-10-10 13:59:08 +00:00
|
|
|
|
|
2023-10-14 13:00:56 +00:00
|
|
|
|
[RequestPacketHandler("LoginRequest")]
|
|
|
|
|
public static void LoginRequestHandler(Session session, Packet.Request packet)
|
2023-10-10 13:59:08 +00:00
|
|
|
|
{
|
|
|
|
|
session.SendResponse(new LoginResponse
|
|
|
|
|
{
|
|
|
|
|
Code = 0,
|
|
|
|
|
ReconnectToken = "eeeeeeeeeeeeeeh",
|
|
|
|
|
UtcOffset = 0,
|
2023-10-14 13:00:56 +00:00
|
|
|
|
UtcServerTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
|
|
|
|
|
}, packet.Id);
|
2023-10-10 18:22:41 +00:00
|
|
|
|
|
2023-10-11 18:32:25 +00:00
|
|
|
|
DoLogin(session);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-11 21:15:35 +00:00
|
|
|
|
// TODO: Move somewhere else, also split.
|
2023-10-11 18:32:25 +00:00
|
|
|
|
static void DoLogin(Session session)
|
|
|
|
|
{
|
2023-10-14 15:05:58 +00:00
|
|
|
|
NotifyLogin notifyLogin = JsonConvert.DeserializeObject<NotifyLogin>(File.ReadAllText("Data/NotifyLogin.json"))!;
|
|
|
|
|
session.SendPush(notifyLogin);
|
2023-10-10 13:59:08 +00:00
|
|
|
|
}
|
2023-10-10 09:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|