Snowflake/RPG.Services.Gameserver/Modules/LoginModule.cs

38 lines
1.2 KiB
C#
Raw Normal View History

2024-01-19 14:45:18 +00:00
using RPG.Network.Proto;
using RPG.Services.Gameserver.Game.Entity;
2024-01-19 14:45:18 +00:00
using RPG.Services.Gameserver.Modules.Attributes;
using RPG.Services.Gameserver.Session;
namespace RPG.Services.Gameserver.Modules;
internal class LoginModule : BaseModule
{
private readonly IEntityEventListener _mazeEventListener;
public LoginModule(ModuleManager moduleManager, IEntityEventListener mazeEventListener) : base(moduleManager)
{
_mazeEventListener = mazeEventListener;
}
2024-01-19 14:45:18 +00:00
[OnCommand(CmdType.CmdPlayerLoginCsReq)]
public async Task OnCmdPlayerLoginCsReq(PlayerSession session, ReadOnlyMemory<byte> body)
2024-01-19 14:45:18 +00:00
{
PlayerLoginCsReq req = PlayerLoginCsReq.Parser.ParseFrom(body.Span);
_mazeEventListener.Session = session;
await ModuleManager.OnLogin();
2024-01-19 14:45:18 +00:00
Send(session, CmdType.CmdPlayerLoginScRsp, new PlayerLoginScRsp
{
Retcode = 0,
LoginRandom = req.LoginRandom,
Stamina = 160,
ServerTimestampMs = (ulong)DateTimeOffset.Now.ToUnixTimeMilliseconds(),
BasicInfo = new()
{
Level = 5,
2024-01-19 15:06:09 +00:00
Nickname = "Snowflake"
2024-01-19 14:45:18 +00:00
}
});
}
}