public static void AddHandler <T>(AuthCMD opcode, ProcessLoginPacketCallbackTypes <T> callback) { AddHandler(opcode, (session, data) => { T generatedHandler = (T)Activator.CreateInstance(typeof(T), data); callback(session, generatedHandler); }); }
internal static void CallHandler(AuthServerSession authServerSession, AuthCMD opcode, byte[] data) { if (MCallbacks.ContainsKey(opcode)) { MCallbacks[opcode](authServerSession, data); } else { Log.Print(LogType.AuthServer, $"Missing handler: {opcode}"); AuthServerSession.DumpPacket(data, authServerSession); } }
private void OnPacket(byte[] data) { short opcode = BitConverter.ToInt16(data, 0); try { AuthCMD code = (AuthCMD)opcode; AuthServerRouter.CallHandler(this, code, data); } catch (Exception e) { var trace = new StackTrace(e, true); Log.Print(LogType.Error, $"{e.Message}: {e.Source}\n{trace.GetFrame(trace.FrameCount - 1).GetFileName()}:{trace.GetFrame(trace.FrameCount - 1).GetFileLineNumber()}"); DumpPacket(data, this); } }
public IPacketHandler GetPacketHandler(byte opcode) { AuthCMD authCMD = (AuthCMD)opcode; return(handlers.ContainsKey(authCMD) ? handlers[authCMD] : null); }
public PacketServer(AuthCMD authOpcode) : this((byte)authOpcode) { }
public static void AddHandler(AuthCMD opcode, ProcessLoginPacketCallback handler) { MCallbacks.Add(opcode, handler); }