WutheringWaves/GameServer/Controllers/LoginController.cs

42 lines
1.4 KiB
C#
Raw Normal View History

2024-02-09 22:15:05 +00:00
using GameServer.Controllers.Attributes;
using GameServer.Network;
using GameServer.Network.Messages;
2024-02-10 16:04:03 +00:00
using GameServer.Systems.Event;
2024-02-09 22:15:05 +00:00
using Microsoft.Extensions.Logging;
using Protocol;
namespace GameServer.Controllers;
internal class LoginController : Controller
{
public LoginController(PlayerSession session) : base(session)
{
// LoginController.
}
[NetEvent(MessageId.LoginRequest)]
public async Task<ResponseMessage> OnLoginRequest(EventSystem eventSystem)
{
await eventSystem.Emit(GameEventType.Login);
return Response(MessageId.LoginResponse, new LoginResponse
{
Code = 0,
Platform = "PC",
Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds()
});
}
[NetEvent(MessageId.EnterGameRequest)]
public async Task<ResponseMessage> OnEnterGameRequest(EnterGameRequest request, ILogger<LoginController> logger, EventSystem eventSystem)
{
logger.LogInformation("Enter Game Request:\n{req}", request);
await eventSystem.Emit(GameEventType.EnterGame);
await Session.Push(MessageId.PushDataCompleteNotify, new PushDataCompleteNotify());
return Response(MessageId.EnterGameResponse, new EnterGameResponse());
}
[NetEvent(MessageId.HeartbeatRequest)]
public ResponseMessage OnHeartbeatRequest() => Response(MessageId.HeartbeatResponse, new HeartbeatResponse());
}