예제 #1
0
        public SharedItem(AresTCPPacketReader packet)
        {
            this.Mime = (Mime)packet.ReadByte();
            this.Size = packet.ReadUInt32();
            ushort len = packet.ReadUInt16();
            this.SearchWords = Encoding.UTF8.GetString(packet.ReadBytes(len)).ToUpper();
            this.Data = packet.ReadBytes();
            this.FileName = null;
            this.Title = null;

            packet = new AresTCPPacketReader(this.Data);
            packet.SkipBytes(18); // 16 guid + 2 detail len

            switch (this.Mime)
            {
                case Mime.ARES_MIME_MP3:
                    packet.SkipBytes(4);
                    break;

                case Mime.ARES_MIME_VIDEO:
                    packet.SkipBytes(6);
                    break;

                case Mime.ARES_MIME_IMAGE:
                    packet.SkipBytes(5);
                    break;
            }

            while (packet.Remaining > 2)
            {
                byte size = packet.ReadByte();
                byte type = packet.ReadByte();

                if (packet.Remaining < size)
                    break;

                byte[] data = packet.ReadBytes(size);

                switch (type)
                {
                    case 1:
                        this.Title = Encoding.UTF8.GetString(data);
                        break;

                    case 15:
                        this.FileName = Encoding.UTF8.GetString(data);
                        break;
                }
            }

            if (this.FileName != null)
                if (this.Title == null)
                    this.Title = this.FileName;
        }
예제 #2
0
        public static void Eval(UserObject userobj, ProtoMessage msg, AresTCPPacketReader packet)
        {
            switch (msg)
            {
                case ProtoMessage.MSG_CHAT_CLIENT_CUSTOM_ADD_TAGS:
                    ProcessAddCustomTag(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_CUSTOM_REM_TAGS:
                    ProcessRemCustomTag(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_CUSTOM_FONT:
                    ProcessCustomFont(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_VC_SUPPORTED:
                    ProcessVCSupported(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_VC_FIRST:
                    ProcessVCFirst(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_VC_FIRST_TO:
                    ProcessVCFirstTo(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_VC_CHUNK:
                    ProcessVCChunk(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_VC_CHUNK_TO:
                    ProcessVCChunkTo(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_VC_IGNORE:
                    ProcessVCIgnore(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_SUPPORTS_CUSTOM_EMOTES:
                    ProcessSupportsCustomEmotes(userobj);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_CUSTOM_EMOTES_UPLOAD_ITEM:
                    ProcessCustomEmoteUpload(userobj, packet);
                    break;

                case ProtoMessage.MSG_CHAT_CLIENT_CUSTOM_EMOTE_DELETE:
                    ProcessCustomEmoteDelete(userobj, packet);
                    break;
            }
        }
예제 #3
0
        private static void ProcessCustomEmoteDelete(UserObject userobj, AresTCPPacketReader packet)
        {
            if (!Settings.CanCustomEmotes)
                return;

            String text = packet.ReadString();
            userobj.CustomEmoticons.RemoveAll(x => x.Shortcut == text);
            byte[] buf = CustomPackets.CustomEmoteDelete(userobj, text);

            UserPool.Users.ForEach(x =>
            {
                if (x.LoggedIn && x.Vroom == userobj.Vroom)
                    if (x.SupportsCustomEmoticons)
                        x.SendPacket(buf);
            });
        }
예제 #4
0
        private static void ProcessCustomEmoteUpload(UserObject userobj, AresTCPPacketReader packet)
        {
            if (!Settings.CanCustomEmotes)
                return;

            ProcessSupportsCustomEmotes(userobj);

            CustomEmoticon emoticon = new CustomEmoticon
            {
                Shortcut = packet.ReadString(),
                Size = packet.ReadByte(),
                Image = packet.ReadBytes()
            };

            userobj.CustomEmoticons.Add(emoticon);

            if (userobj.CustomEmoticons.Count > 16)
                throw new Exception("exceeded custom emoticon maximum");

            byte[] buf = CustomPackets.CustomEmoteItem(userobj, emoticon);

            UserPool.Users.ForEach(x =>
            {
                if (x.LoggedIn && x.Vroom == userobj.Vroom)
                    if (x.SupportsCustomEmoticons)
                        x.SendPacket(buf);
            });
        }
예제 #5
0
 private static void ProcessAddCustomTag(UserObject userobj, AresTCPPacketReader packet)
 {
     while (packet.Remaining > 0)
         userobj.CustomTags.Add(packet.ReadString());
 }
예제 #6
0
 private static void ProcessVCSupported(UserObject userobj, AresTCPPacketReader packet)
 {
     if (Settings.CanVoiceChat)
     {
         userobj.CanVCPublic = packet.ReadByte() == 1;
         userobj.CanVCPrivate = packet.ReadByte() == 1;
         UserPool.BroadcastToVroom(userobj.Vroom, CustomPackets.VoiceChatUserSupport(userobj));
     }
 }
예제 #7
0
        private static void ProcessVCIgnore(UserObject userobj, AresTCPPacketReader packet)
        {
            if (Settings.CanVoiceChat)
            {
                String name = packet.ReadString();

                if (userobj.VCIgnores.Contains(name))
                {
                    userobj.SendPacket(AresTCPPackets.NoSuch(name + " is voice chat unignored"));
                    userobj.VCIgnores.RemoveAll(x => x == name);
                }
                else
                {
                    userobj.SendPacket(AresTCPPackets.NoSuch(name + " is voice chat ignored"));
                    userobj.VCIgnores.Add(name);
                }
            }
        }
예제 #8
0
        private static void ProcessVCFirstTo(UserObject userobj, AresTCPPacketReader packet)
        {
            if (Settings.CanVoiceChat)
            {
                String name = packet.ReadString();
                UserObject target = UserPool.Users.Find(x => x.LoggedIn && x.Name == name);

                if (target != null)
                    if (!target.VCIgnores.Contains(userobj.Name))
                        if (target.CanVCPrivate)
                        {
                            byte[] buffer = CustomPackets.VoiceChatFirstTo(userobj.Name, packet.ReadBytes());
                            target.SendPacket(buffer);
                        }
                        else userobj.SendPacket(CustomPackets.VoiceChatNoPrivate(target.Name));
                    else userobj.SendPacket(CustomPackets.VoiceChatIgnored(target.Name));
                else userobj.SendPacket(AresTCPPackets.OfflineUser(name));
            }
        }
예제 #9
0
 private static void ProcessVCFirst(UserObject userobj, AresTCPPacketReader packet)
 {
     if (Settings.CanVoiceChat)
     {
         byte[] buffer = CustomPackets.VoiceChatFirst(userobj.Name, packet.ReadBytes());
         UserPool.BroadcastVoiceClip(userobj, buffer);
     }
 }
예제 #10
0
 private static void ProcessRemCustomTag(UserObject userobj, AresTCPPacketReader packet)
 {
     while (packet.Remaining > 0)
     {
         String str = packet.ReadString();
         userobj.CustomTags.Remove(str);
     }
 }
예제 #11
0
 private static void ProcessCustomFont(UserObject userobj, AresTCPPacketReader packet)
 {
     if (packet.Remaining == 2)
     {
         userobj.Font = null;
         UserPool.BroadcastToVroom(userobj.Vroom, CustomPackets.CustomFontDefault(userobj));
     }
     else
     {
         userobj.Font = new Font(packet.ReadByte(), packet.ReadString(), packet.ReadByte(), packet.ReadByte());
         UserPool.BroadcastToVroom(userobj.Vroom, CustomPackets.CustomFont(userobj));
     }
 }
예제 #12
0
 public void PopulateCredentials(AresTCPPacketReader packet)
 {
     this.Guid = packet.ReadGuid();
     this.FileCount = packet.ReadUInt16();
     packet.SkipByte(); // not used
     this.Port = packet.ReadUInt16();
     this.NodeIP = packet.ReadIP();
     this.NodePort = packet.ReadUInt16();
     packet.SkipBytes(4); // line speed
     this.OrgName = packet.ReadString();
     this.OrgName = UserPool.PrepareUserName(this);
     this.name = this.OrgName;
     this.Version = packet.ReadString();
     this.LocalIP = packet.ReadIP();
     packet.SkipBytes(4); // external ip
     this.CanBrowse = packet.ReadByte() >= 3;
     this.FileCount = this.CanBrowse ? this.FileCount : (ushort)0;
     this.CurrentUploads = packet.ReadByte();
     this.MaxUploads = packet.ReadByte();
     this.CurrentQueued = packet.ReadByte();
     this.Age = packet.ReadByte();
     this.Sex = packet.ReadByte();
     this.Country = packet.ReadByte();
     this.Location = packet.ReadString();
     this.Muzzled = Muzzles.IsMuzzled(this);
 }