forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGamePacketHandlerAuth.cs
More file actions
45 lines (37 loc) · 1.66 KB
/
Copy pathGamePacketHandlerAuth.cs
File metadata and controls
45 lines (37 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Concurrent;
using L2dotNET.Network.loginauth;
using L2dotNET.Network.loginauth.recv;
using NLog;
namespace L2dotNET.Network
{
public class GamePacketHandlerAuth
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
private static readonly ConcurrentDictionary<byte, Type> LoginServerPackets = new ConcurrentDictionary<byte, Type>();
private readonly IServiceProvider _serviceProvider;
public GamePacketHandlerAuth(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
LoginServerPackets.TryAdd(0xA1, typeof(LoginServPingResponse));
LoginServerPackets.TryAdd(0xA5, typeof(LoginServLoginFail));
LoginServerPackets.TryAdd(0xA6, typeof(LoginServLoginOk));
LoginServerPackets.TryAdd(0xA7, typeof(LoginServAcceptPlayer));
LoginServerPackets.TryAdd(0xA8, typeof(LoginServKickAccount));
}
public void HandlePacket(Packet packet, AuthThread login)
{
PacketBase packetBase = null;
Log.Info($"Received packet with Opcode:{packet.FirstOpcode:X2}");
if (LoginServerPackets.ContainsKey(packet.FirstOpcode))
{
packetBase = (PacketBase)Activator.CreateInstance(LoginServerPackets[packet.FirstOpcode], _serviceProvider, packet, login);
}
if (packetBase == null)
{
throw new ArgumentNullException(nameof(packetBase), $"Packet with opcode: {packet.FirstOpcode:X2} doesn't exist in the dictionary.");
}
packetBase.RunImpl();
}
}
}