Snowflake/RPG.Services.Gameserver/Session/PlayerSession.cs

29 lines
880 B
C#
Raw Normal View History

2024-01-19 14:45:18 +00:00
using Microsoft.Extensions.DependencyInjection;
using RPG.Network.Proto;
using RPG.Services.Core.Network;
2024-01-18 22:13:40 +00:00
using RPG.Services.Core.Session;
2024-01-19 14:45:18 +00:00
using RPG.Services.Gameserver.Modules;
2024-01-18 22:13:40 +00:00
namespace RPG.Services.Gameserver.Session;
internal class PlayerSession : RPGSession
{
2024-01-19 14:45:18 +00:00
private readonly IServiceScope _scope;
private readonly ModuleManager _moduleManager;
public PlayerSession(ulong sessionId, ServiceBox serviceBox, IServiceScopeFactory scopeFactory) : base(sessionId, serviceBox)
{
_scope = scopeFactory.CreateScope();
_moduleManager = _scope.ServiceProvider.GetRequiredService<ModuleManager>();
}
public async Task HandleGameCommand(ushort cmdType, ReadOnlyMemory<byte> body)
{
await _moduleManager.HandleAsync(this, (CmdType)cmdType, body);
}
public override void Dispose()
2024-01-18 22:13:40 +00:00
{
2024-01-19 14:45:18 +00:00
_scope.Dispose();
2024-01-18 22:13:40 +00:00
}
}