コード例 #1
0
ファイル: SharedItem.cs プロジェクト: hollow87/Arca4
        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
        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);
            });
        }
コード例 #3
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));
            }
        }
コード例 #4
0
 private static void ProcessVCFirst(UserObject userobj, AresTCPPacketReader packet)
 {
     if (Settings.CanVoiceChat)
     {
         byte[] buffer = CustomPackets.VoiceChatFirst(userobj.Name, packet.ReadBytes());
         UserPool.BroadcastVoiceClip(userobj, buffer);
     }
 }