コード例 #1
0
ファイル: NormalIMText.cs プロジェクト: leaker/fuhj-widgets
 public void Read(ByteBuffer buf)
 {
     buf.Get();//0x01
        int len=buf.GetUShort();
        Text = Utils.Util.GetString(buf.GetByteArray(len));
        if (buf.HasRemaining())
        {
        RemainBytes = buf.GetByteArray(buf.Remaining());
        QQClient.LogManager.Log("NormalIMText Class Parse Buf Remaining Data:" + Utils.Util.ToHex(RemainBytes));
        }
 }
コード例 #2
0
 public bool Accept(ByteBuffer buf)
 {
     //保存偏移
     offset = buf.Position;
     int bufferLength = buf.Remaining();
     if (bufferLength <= 0)
         return false;
     bool accept = CheckTcp(buf);
     if (!accept)
         accept = CheckUdp(buf);
     return accept;
 }
コード例 #3
0
ファイル: FileInfo.cs プロジェクト: leaker/fuhj-widgets
 /// <summary>
 /// 给定一个输入流,解析SendFileRequest结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     // 跳过空格符和分隔符
     buf.GetChar();
     // 获取后面的所有内容
     byte[] b = buf.GetByteArray(buf.Remaining());
     // 找到分隔符
     int i = Array.IndexOf<byte>(b, 0, (byte)0x1F);
     // 得到文件名
     FileName = Utils.Util.GetString(b, 0, i);
     // 得到文件大小的字符串形式
     String sizeStr = Utils.Util.GetString(b, i + 1, b.Length - 6 - i);
     FileSize = Utils.Util.GetInt(sizeStr, 0);
 }
コード例 #4
0
        /// <summary>
        /// 解析包体,从buf的开头位置解析起
        /// <remark>abu 2008-02-18 </remark>
        /// </summary>
        /// <param name="buf">The buf.</param>
        protected override void ParseBody(ByteBuffer buf)
        {
            #if DEBUG
            Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
            #endif
            Empty = false;
            // 检查消息长度,至少要有16字节,因为我们需要前16字节做为确认发回
            if (buf.Remaining() < 16)
            {
                throw new PacketParseException("收到的消息太短,抛弃该消息");
            }
            // 得到前16个字节用作回复
            Reply = buf.GetByteArray(16);
            // 读取消息头
            buf.Position = 0;
            Header = new ReceiveIMHeader();
            Header.Read(buf);
            // 检查输入流可用字节
            if (!buf.HasRemaining())
            {
                Empty = true;
                return;
            }
            // 判断消息类型
            int len = 0;
            switch (Header.Type)
            {
                case RecvSource.FRIEND_0801: //手机消息
                    buf.Position += 10;//buf.GetInt();
                    ParseNormalIM(buf);
                    break;
                case RecvSource.FRIEND_0802:
                    ParseNormalIM(buf);
                    break;
                case RecvSource.FRIEND_09:
                    buf.Position += 11;
                    ParseNormalIM(buf);
                    break;
                case RecvSource.FRIEND_09SP1:
                    buf.Position += 2;
                    int len1 = buf.GetUShort();
                    buf.Position += len1;
                    ParseNormalIM(buf);
                    break;
                case RecvSource.STRANGER:
                    /* 是从好友或者陌生人处发来的消息 */
                    ParseNormalIM(buf);
                    break;

                case RecvSource.TEMP_SESSION:
                    TempSessionIM = new TempSessionIM();
                    TempSessionIM.Read(buf);
                    break;
                case RecvSource.SYS_MESSAGE:
                    /* 是系统消息 */
                    buf.GetInt();//00 00 00 00
                    ParseSystemMessage(buf);
                    break;
                case RecvSource.CLUSTER_09:
                    /* 群消息09 */
                    ParseClusterIM09(buf);
                    break;
                case RecvSource.CLUSTER:

                    /* 群消息 */
                    ParseClusterIM(buf);
                    break;
                case RecvSource.TEMP_CLUSTER:
                    /* 临时群消息 */
                    ParseTempClusterIM(buf);
                    break;
                case RecvSource.UNKNOWN_CLUSTER:
                    ParseUnknownClusterIM(buf);
                    break;
                case RecvSource.BIND_USER:
                    SMS = new SMS();
                    SMS.ReadBindUserSMS(buf);
                    break;
                case RecvSource.MOBILE_QQ:
                    SMS = new SMS();
                    SMS.ReadMobileQQSMS(buf);
                    break;
                case RecvSource.MOBILE_QQ_2 :
                    SMS = new SMS();
                    SMS.ReadMobileQQ2SMS(buf);
                    break;
                case RecvSource.MOBILE:
                    SMS = new SMS();
                    SMS.ReadMobileSMS(buf);
                    break;
                case RecvSource.CREATE_CLUSTER:
                case RecvSource.ADDED_TO_CLUSTER:
                case RecvSource.DELETED_FROM_CLUSTER:
                    ExternalId = buf.GetInt();
                    ClusterType = (ClusterType)buf.Get();
                    Sender = buf.GetInt();
                    break;
                case RecvSource.APPROVE_JOIN_CLUSTER:
                case RecvSource.REJECT_JOIN_CLUSTER:
                case RecvSource.REQUEST_JOIN_CLUSTER:
                    ExternalId = buf.GetInt();
                    ClusterType = (ClusterType)buf.Get();
                    Sender = buf.GetInt();
                    len = buf.Get() & 0xFF;
                    byte[] b = buf.GetByteArray(len);
                    Message = Utils.Util.GetString(b);
                    break;
                case RecvSource.CLUSTER_NOTIFICATION:
                    ExternalId = buf.GetInt();
                    ClusterType = (ClusterType)buf.Get();
                    OpCode = buf.Get();
                    MemberQQ = buf.GetInt();
                    Role = buf.Get();
                    Sender = ExternalId;
                    break;
                case RecvSource.SIGNATURE_CHANGE:
                    SignatureOwner = buf.GetInt();
                    ModifiedTime = buf.GetInt();
                    len = buf.Get() & 0xFF;
                    Signature = Utils.Util.GetString(buf, len);
                    break;
                case RecvSource.QQLIVE:
                    QQLive = new QQLive();
                    QQLive.Read(buf);
                    break;
                case RecvSource.MEMBER_LOGIN_HINT:
                    buf.Get();
                    break;
                case RecvSource.CUSTOM_HEAD_CHANGE:
                    int count = buf.Get() & 0xFF;
                    if (count > 0)
                    {
                        HeadChanges = new List<CustomHead>();
                        while (buf.HasRemaining())
                        {
                            CustomHead change = new CustomHead();
                            change.Read(buf);
                            HeadChanges.Add(change);
                        }
                    }
                    break;
                case RecvSource.PROPERTY_CHANGE :
                    PropertyChange = new UserPropertyChange();
                    PropertyChange.Read(buf);
                    break;
                case RecvSource.INPUT_STATE_CHANGE: //输入状态
                    buf.GetInt();//00 00 00 00
                    Sender = buf.GetInt();//09 58 8C 87
                    buf.Get();//00
                    break;
                default:
                    // 其他类型的消息我们现在没有办法处理,忽略
                    Client.LogManager.Log(ToString() + " Unknown RecvSource=0x" + Header.Type.ToString("X"));
                    break;
            }
        }
コード例 #5
0
ファイル: NormalIM.cs プロジェクト: leaker/fuhj-widgets
        /// <summary>
        /// 分析09的流
        /// </summary>
        /// <param name="buf"></param>
        public void Read09(ByteBuffer buf)
        {
            FontStyle = new FontStyle();
            // 是否有字体属性
            HasFontAttribute = buf.GetInt() != 0;
            // 分片数
            TotalFragments = (int)buf.Get();
            // 分片序号
            FragmentSequence = (int)buf.Get();
            // 消息id 两个字节
            MessageId = (int)buf.GetUShort();
            // 消息类型,这里的类型表示是正常回复还是自动回复之类的信息
            ReplyType = (ReplyType)buf.Get();
            // 消息正文
            #region 字体属性开始 未处理
            buf.Position += 8;//'M' 'S' 'G' 00 00 00 00 00
            buf.GetInt();//send time
            buf.Position += 12;//5D 69 71 DE 00 80 80 00 0A 00 86 00  参见sendim
            int len = buf.GetUShort();
            buf.GetByteArray(len);//字体 E5 AE 8B E4 BD 93 =宋体
            #endregion
            buf.GetUShort();//00 00
            IsNormalIM09 = true;//标注09的信息
            MessageBytes = buf.GetByteArray(buf.Remaining());
            //_Message = "";
            //while (buf.HasRemaining())
            //{
            //    byte type = buf.Get();
            //    len = buf.GetUShort();
            //    switch (type)
            //    {
            //        case 0x01://pure text
            //            //len_str = buf.GetUShort();
            //            _Message +=new NormalIMText(QQClient,buf.GetByteArray(len)).ToString();
            //            break;
            //        case 0x02://face
            //            _Message += new NormalIMFace(QQClient, buf.GetByteArray(len)).ToString();
            //            break;
            //        case 0x06://image
            //            _Message += new NormalIMImage(QQClient, buf.GetByteArray(len)).ToString();
            //            break;
            //        default:
            //            QQClient.LogManager.Log(ToString() + " Class Parse Unknown Type=0x" + type.ToString("X") + " Data=" + Utils.Util.ToHex(buf.GetByteArray(len)));
            //            break;

            //    }

            //}
        }
コード例 #6
0
ファイル: NormalIM.cs プロジェクト: leaker/fuhj-widgets
 /// <summary>给定一个输入流,解析NormalIM结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     FontStyle = new FontStyle();
     // 是否有字体属性
     HasFontAttribute = buf.GetInt() != 0;
     // 分片数
     TotalFragments = (int)buf.Get();
     // 分片序号
     FragmentSequence = (int)buf.Get();
     // 消息id 两个字节
     MessageId = (int)buf.GetUShort();
     // 消息类型,这里的类型表示是正常回复还是自动回复之类的信息
     ReplyType = (ReplyType)buf.Get();
     // 消息正文,长度=剩余字节数 - 包尾字体属性长度
     int remain = buf.Remaining();
     int fontAttributeLength = HasFontAttribute ? (buf.Get(buf.Position + remain - 1) & 0xFF) : 0;
     MessageBytes = buf.GetByteArray(remain - fontAttributeLength);
     // 这后面都是字体属性,这个和SendIMPacket里面的是一样的
     if (HasFontAttribute)
     {
         if (buf.HasRemaining())
             FontStyle.Read(buf);
         else
             HasFontAttribute = false;
     }
 }
コード例 #7
0
 public int Relocate(ByteBuffer buf)
 {
     int offset = buf.Position;
     if (buf.Remaining() < 2)
         return offset;
     int len = buf.GetUShort(offset);
     if (len <= 0 || offset + len > buf.Length)
         return offset;
     else
         return offset + len;
 }
コード例 #8
0
ファイル: NormalIMImage.cs プロジェクト: leaker/fuhj-widgets
        public void Read(ByteBuffer buf)
        {
            while (buf.HasRemaining())
               {
               byte type = buf.Get();
               int len = buf.GetUShort();
               switch (type)
               {
                   case 0x02:
                       FileName = Utils.Util.GetString(buf.GetByteArray(len));
                       break;
                   case 0x03://filesize
                       FileSize =(int) Utils.Util.GetUInt(buf.GetByteArray(len), 0, 4); //buf.GetInt();
                       break;
                   case 0x04://guid
                       FGuid = Utils.Util.GetString(buf.GetByteArray(len));
                       break;
                   case 0xff:
                       FFData = buf.GetByteArray(len);
                       break;
                   default:
                       QQClient.LogManager.Log(base.ToString()+" Parse Error,Unknown Type=" + type.ToString("X") + ": Data=" + Utils.Util.ToHex(buf.GetByteArray(len)));
                       break;

               }
               }
               if (buf.HasRemaining())
               {
               RemainBytes = buf.GetByteArray(buf.Remaining());
               QQClient.LogManager.Log(base.ToString() + " Class Parse Buf Remaining Data:" + Utils.Util.ToHex(RemainBytes));
               }
        }
コード例 #9
0
ファイル: NormalIMFace.cs プロジェクト: leaker/fuhj-widgets
        public void Read( ByteBuffer buf)
        {
            while (buf.HasRemaining())
               {
               byte type = buf.Get();
               int len = buf.GetUShort();
               switch (type)
               {
                   case 0x01:
                       FaceId = buf.Get();
                       break;
                   case 0xff:
                       FFData = buf.GetByteArray(len);
                       break;
                   default:
                       QQClient.LogManager.Log(base.ToString()+" Parse Error,Unknown Type=" + type.ToString("X") + ": Data=" + Utils.Util.ToHex(buf.GetByteArray(len)));
                       break;

               }
               }
               if (buf.HasRemaining())
               {
               RemainBytes = buf.GetByteArray(buf.Remaining());
               QQClient.LogManager.Log(base.ToString() + " Class Parse Buf Remaining Data:" + Utils.Util.ToHex(RemainBytes));
               }
        }