Esempio n. 1
0
        public static void Eval(AresClient client, TCPPacket packet, ulong time)
        {
            if (!client.LoggedIn && (packet.Msg > TCPMsg.MSG_CHAT_CLIENT_LOGIN && packet.Msg != TCPMsg.MSG_LINK_PROTO))
            {
                throw new Exception("unordered login routine");
            }

            if (client.LoggedIn)
            {
                if (FloodControl.IsFlooding(client, packet.Msg, packet.Packet.ToArray(), time))
                {
                    if (Events.Flooding(client, (byte)packet.Msg))
                    {
                        Events.Flooded(client);
                        client.Disconnect();
                        return;
                    }
                }
            }

            switch (packet.Msg)
            {
            case TCPMsg.MSG_CHAT_CLIENT_LOGIN:
            case TCPMsg.MSG_CHAT_CLIENT_RELOGIN:
                Login(client, packet.Packet, time, packet.Msg == TCPMsg.MSG_CHAT_CLIENT_RELOGIN);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_UPDATE_STATUS:
                client.Time = time;
                client.SendPacket(TCPOutbound.UpdateUserStatus(client, client));
                break;

            case TCPMsg.MSG_CHAT_CLIENT_AVATAR:
                Avatar(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_PERSONAL_MESSAGE:
                PersonalMessage(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_FASTPING:
                client.FastPing = true;
                break;

            case TCPMsg.MSG_CHAT_CLIENT_CUSTOM_DATA:
                CustomData(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_CUSTOM_DATA_ALL:
                CustomDataAll(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL:
                TCPAdvancedProcessor.Eval(client, packet, time);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_PUBLIC:
                Public(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_EMOTE:
                Emote(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_COMMAND:
                Command(client, packet.Packet.ReadString(client));
                break;

            case TCPMsg.MSG_CHAT_CLIENT_PVT:
                Private(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_IGNORELIST:
                IgnoreList(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_ADDSHARE:
                FileBrowseProcessor.AddShare(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_REMSHARE:
                FileBrowseProcessor.RemShare(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_BROWSE:
                FileBrowseProcessor.Browse(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_SEARCH:
                FileBrowseProcessor.Search(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_AUTHLOGIN:
                Command(client, "login " + packet.Packet.ReadString(client));
                break;

            case TCPMsg.MSG_CHAT_CLIENT_AUTHREGISTER:
                Command(client, "register " + packet.Packet.ReadString(client));
                break;

            case TCPMsg.MSG_CHAT_CLIENT_AUTOLOGIN:
                SecureLogin(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_DUMMY:
                Dummy(client);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_DIRCHATPUSH:
                DirChatPush(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_SEND_SUPERNODES:
                client.SendPacket(TCPOutbound.SuperNodes());
                break;

            case TCPMsg.MSG_LINK_PROTO:
                LinkProto(client, packet.Packet, time);
                break;

            default:
                Events.UnhandledProtocol(client, false, packet.Msg, packet.Packet, time);
                break;
            }
        }