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
39 lines (33 loc) · 1.49 KB
/
GamePacketHandlerAuth.cs
File metadata and controls
39 lines (33 loc) · 1.49 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
using System;
using System.Collections.Concurrent;
using System.Runtime.Remoting.Contexts;
using log4net;
using L2dotNET.Network.loginauth;
using L2dotNET.Network.loginauth.recv;
namespace L2dotNET.Network
{
[Synchronization]
public class GamePacketHandlerAuth
{
private static readonly ILog Log = LogManager.GetLogger(typeof(GamePacketHandlerAuth));
private static readonly ConcurrentDictionary<byte, Type> ClientPackets = new ConcurrentDictionary<byte, Type>();
static GamePacketHandlerAuth()
{
ClientPackets.TryAdd(0xA1, typeof(LoginServPingResponse));
ClientPackets.TryAdd(0xA5, typeof(LoginServLoginFail));
ClientPackets.TryAdd(0xA6, typeof(LoginServLoginOk));
ClientPackets.TryAdd(0xA7, typeof(LoginServAcceptPlayer));
ClientPackets.TryAdd(0xA8, typeof(LoginServKickAccount));
}
public static void HandlePacket(Packet packet, AuthThread login)
{
PacketBase packetBase = null;
Log.Info($"Received packet with Opcode:{packet.FirstOpcode:X2}");
if (ClientPackets.ContainsKey(packet.FirstOpcode))
packetBase = (PacketBase)Activator.CreateInstance(ClientPackets[packet.FirstOpcode], packet, login);
if (packetBase == null)
throw new ArgumentNullException(nameof(packetBase), $"Packet with opcode: {packet.FirstOpcode:X2} doesn't exist in the dictionary.");
packetBase.RunImpl();
}
}
}