Пример #1
0
 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);
     });
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
        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);
            }
        }
Пример #4
0
    public IPacketHandler GetPacketHandler(byte opcode)
    {
        AuthCMD authCMD = (AuthCMD)opcode;

        return(handlers.ContainsKey(authCMD) ? handlers[authCMD] : null);
    }
Пример #5
0
 public PacketServer(AuthCMD authOpcode) : this((byte)authOpcode)
 {
 }
Пример #6
0
 public static void AddHandler(AuthCMD opcode, ProcessLoginPacketCallback handler)
 {
     MCallbacks.Add(opcode, handler);
 }