using Microsoft.Extensions.Logging; using RPG.Network.Proto; using RPG.Services.Core.Network; using RPG.Services.Core.Network.Attributes; using RPG.Services.Core.Network.Command; using RPG.Services.Core.Session; using RPG.Services.Gameserver.Session; namespace RPG.Services.Gameserver.Network.Command; internal class GameserverCommandHandler : ServiceCommandHandler { private readonly SessionManager _sessionManager; public GameserverCommandHandler(ILogger logger, ServiceBox services, SessionManager sessionManager) : base(logger, services) { _sessionManager = sessionManager; } [ServiceCommand(ServiceCommandType.BindContainer)] public Task OnCmdBindContainer(ServiceCommand command) { CmdBindContainer cmdBindContainer = CmdBindContainer.Parser.ParseFrom(command.Body.Span); PlayerSession? session = _sessionManager.Create(cmdBindContainer.SessionId); if (session == null) { Send(ServiceCommandType.BindContainerResult, new CmdBindContainerResult { Retcode = 1, SessionId = cmdBindContainer.SessionId }, command.SenderType); return Task.CompletedTask; } session.PlayerUid = cmdBindContainer.PlayerUid; Send(ServiceCommandType.BindContainerResult, new CmdBindContainerResult { Retcode = 0, SessionId = cmdBindContainer.SessionId }, command.SenderType); return Task.CompletedTask; } }