当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.GetByteArray方法代码示例

本文整理汇总了C#中System.ByteBuffer.GetByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.GetByteArray方法的具体用法?C# ByteBuffer.GetByteArray怎么用?C# ByteBuffer.GetByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.GetByteArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseBody

        protected override void ParseBody(ByteBuffer buf)
        {
            #if DEBUG
            Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray()));
            #endif

            buf.GetChar();//length or sth..
            ReplyCode = buf.Get();
            int len = 0;
            switch (ReplyCode)
            {
                case 0x00://success!
                    Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Login Success!");
                    len = buf.GetChar();//0x0020
                    Client.QQUser.QQKey.LoginInfo_Token = buf.GetByteArray(len);
                    Client.QQUser.QQKey.LoginInfo_UnknowData = buf.GetByteArray(4); //buf.GetInt()
                    Client.ServerTime = buf.GetByteArray(4);

                    len = buf.GetChar();
                    Client.QQUser.QQKey.LoginInfo_Data_Token = buf.GetByteArray(len);
                    len = buf.GetChar();
                    Client.QQUser.QQKey.LoginInfo_Magic_Token = buf.GetByteArray(len);
                    Client.QQUser.QQKey.LoginInfo_Key1 = buf.GetByteArray(16);
                    buf.GetChar();//0x00 00
                    if (buf.Position + 3 < buf.Length)//判断来的包是否包含LoginInfo_Key3 因为有的版本没这个key 应该说本人用的正式版本没这个
                    {
                        Client.QQUser.QQKey.LoginInfo_Key3 = buf.GetByteArray(16);
            #if DEBUG
                        Client.LogManager.Log(ToString() + "Client.QQUser.QQKey.LoginInfo_Key3:" + Utils.Util.ToHex(Client.QQUser.QQKey.LoginInfo_Key3));
            #endif
                    }
                    buf.GetChar();//0x00 00
                    return;
                case 0x33:
                case 0x51://denied!
                    Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Denied!");
                    break;
                case 0xBF:
                    Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " No this QQ number!");
                    break;
                case 0x34:
                    Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Wrong password!");
                    break;
                default:
                    Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Unknow ReplyCode!");
                    break;

            }
            buf.Position = 11;
            len =(int) buf.GetChar();
            byte[] data = buf.GetByteArray(len);
            ReplyMessage = Utils.Util.GetString(data);

            Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Message Data(UTF-8): "+Utils.Util.ToHex(data)+"-->" + ReplyMessage);
        }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:55,代码来源:LoginVerifyReplyPacket.cs

示例2: Read

 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));
        }
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:11,代码来源:NormalIMText.cs

示例3: Read

 public void Read(ByteBuffer buf)
 {
     //振动 00 00 00 01 00 09 41 A1 34 00 00 00 00
        //输入 00 00 00 01
        buf.GetInt();// 00 00 00 01
        if (buf.HasRemaining())
        {
        //long l=buf.GetLong();
        buf.Get();//0
      int qq=  buf.GetInt(); //QQ号码
        buf.GetByteArray(3);//未知 00 00 00
      //byte[] data=  buf.GetByteArray(8);
      //byte[] comparedata = new byte[] { 0x00, 0x09, 0x41, 0xA1, 0x34, 0x00, 0x00, 0x00 };
      //long l = BitConverter.ToInt64(data, 0);
      //long l2 = BitConverter.ToInt64(comparedata, 0);
      //  if (l == l2)
      //  {
            IsShake = true;
        //}
        }
        else
        {
        IsInputState = true;
        }
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:25,代码来源:Vibration.cs

示例4: Read

 public void Read(ByteBuffer buf)
 {
     Id = (uint)buf.Get();
     Path = buf.GetUInt();
     int len = (int)buf.Get();
     Name = Utils.Util.GetString(buf.GetByteArray(len));
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:7,代码来源:QQOrganization.cs

示例5: ParseBody

 protected override void ParseBody(ByteBuffer buf)
 {
     ReplyCode = (ReplyCode)buf.Get();
     if (ReplyCode == ReplyCode.OK)
     {
         int len = buf.Get() & 0xFF;
         LoginToken = buf.GetByteArray(len);
     }
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:9,代码来源:RequestLoginTokenReplyPacket.cs

示例6: ParseBody

 protected override void ParseBody(ByteBuffer buf)
 {
     #if DEBUG
     Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray()));
     #endif
     buf.Get();//00
     Onlines = buf.GetInt();
     IP = Utils.Util.GetIpStringFromBytes(buf.GetByteArray(4));//client ip
     Port = (int)buf.GetChar();
     buf.GetChar();//unknown 00 3c
     ServerTime = Utils.Util.GetDateTimeFromMillis(buf.GetInt() * 1000L);
     Client.LogManager.Log(ToString() + " Onlines:" +Onlines.ToString()+" IP:"+IP+" ServerTime:"+ServerTime.ToString());
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:13,代码来源:KeepAliveReplyPacket.cs

示例7: Read

 /// <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);
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:18,代码来源:FileInfo.cs

示例8: ParseBody

 protected override void ParseBody(ByteBuffer buf)
 {
     #if DEBUG
     Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray()));
     #endif
     buf.GetChar();//01 66 length or sth...
     buf.GetChar();//01 00
     Client.QQUser.QQKey.LoginInfo_Key2 = buf.GetByteArray(16);
     buf.Position += 8;//00 00 00 01 00 00 00 64
     Client.QQUser.QQKey.LoginInfo_UnknowData2 = buf.GetByteArray(4);
     Client.ServerTime = buf.GetByteArray(4);
     Client.ClientIP = buf.GetByteArray(4);
     buf.GetInt();//00000000
     int len = (int)buf.GetChar();
     Client.QQUser.QQKey.LoginInfo_Large_Token = buf.GetByteArray(len);
     buf.GetInt();//????
     len = (int)buf.Get();
     NickName = Utils.Util.GetString(buf.GetByteArray(len));
     Client.LogManager.Log(ToString() + ": Hello," + NickName);
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:20,代码来源:LoginGetInfoReplyPacket.cs

示例9: ParseBody

        protected override void ParseBody(ByteBuffer buf)
        {
            //怎么我得到的数据是//01 00 05 00 00 20 78 09 D7 43 99 8B DD 87 59 82 EA 85 7D 09 9A B2 92 77 53 5B 6D E3 6C B6 66 B3 21 75 6B 0B 37 85
            #if DEBUG
            Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray()));
            #endif
            ReplyCode = buf.Get();//03: ok   04: need verifying 可是我得到的是01是由于前面错了了一个byte
            buf.Get();//0x00
            buf.Get();//0x05
            Png_Data = buf.Get();
            int len = 0;
            if (Png_Data == 0x00 && ReplyCode == 0x01)
            {
                len = (int)buf.Get();
                while (len == 0)
                {
                    len = (int)buf.Get();
                }
            }
            else //ReplyCode != 0x01按下面走 兼容多版本
            {
                buf.GetInt();//需要验证码时为00 00 01 23,不需要时为全0
                len=(int)buf.GetChar();
            }
            Answer_Token = buf.GetByteArray(len);
            if (Png_Data== 0x01)//有验证码数据
            {
                len = (int)buf.GetChar();
                byte[] data = buf.GetByteArray(len);
                buf.Get();
                Next = buf.Get();
                string directory = Utils.Util.MapPath("/Verify/");
                this.CodeFileName = Path.Combine(directory, Client.QQUser.QQ + ".png");
                FileStream fs=null;
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                if (Next != 0x00)
                {
                    fs = new FileStream(this.CodeFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);

                }
                else fs = new FileStream(this.CodeFileName, FileMode.Append, FileAccess.Write, FileShare.Read);
                //fs.Seek(0, SeekOrigin.End);
                fs.Write(data,0,data.Length);
                fs.Close();
                fs=null;

                len = (int)buf.GetChar();
                Png_Token = buf.GetByteArray(len);
            }

            //
            if (Png_Data!=0x00)
            {
                if (Next!=0x00)
                {
                    //prot_login_request(qq, &png_token, 0, 1);
                    Client.LogManager.Log("接收到部分验证码图片数据,继续接收....");
                    OutPacket outPacket = new LoginRequestPacket(Client, Png_Token, 0, 1);//发送一个请求验证码的包
                    Client.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name);
                }
                else
                {
                    //qq->data.verify_token = answer_token;
                    //qqclient_set_process(qq, P_VERIFYING);
                    Client.LoginStatus = LoginStatus.NeedVerifyCode;
                    Client.QQUser.QQKey.Verify_Token = Answer_Token;
                    Client.LogManager.Log("Need input Verify Code");
                    //Client.LoginManager.OnLoginNeedVerifyCode(e);
                }
            }
            else
            {
                //DBG("process verify password");
                //qq->data.token_c = answer_token;
                //prot_login_verify(qq);
                Client.LogManager.Log("Process LoginRequest Success! Now Process Verify Password...");
                Client.QQUser.QQKey.Answer_Token = Answer_Token;
                OutPacket outPacket = new LoginVerifyPacket(Client);//发送一个登陆请求包
                Client.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name);
            }
        }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:84,代码来源:LoginRequestReplyPacket.cs

示例10: Read09

        /// <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;

            //    }

            //}
        }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:53,代码来源:NormalIM.cs

示例11: ParseBody

        protected override void ParseBody(ByteBuffer buf)
        {
            #if DEBUG
            Client.LogManager.Log(ToString() + " Decoded data:" + Utils.Util.ToHex(buf.ToByteArray()));
            #endif
            //byte result = buf.Get();
            IsRedirect = false;
            ReplyCode = (ReplyCode)buf.Get();
            if (ReplyCode == ReplyCode.OK)
            {
                ServerTime = buf.GetByteArray(4);
                ClientIP = buf.GetByteArray(4);
                buf.Position += 9;
                int len = (int)buf.Get();
                Token = buf.GetByteArray(len);
                byte result=buf.Get();
                if (result != 0x00)
                {
                    IsRedirect = true;
                    Client.LoginRedirect = true;
                    Client.ServerInfo.CSP_wRedirectCount = result;
                    Client.ServerInfo.CSP_cRedirectCount = buf.Get();
                    Client.ServerInfo.CSP_dwConnIspID = buf.GetByteArray(4);
                    Client.ServerInfo.CSP_dwServerReserve = buf.GetByteArray(4);
                    RedirectIP=buf.GetByteArray(4);
                    Client.ServerInfo.CSP_dwConnIP =RedirectIP ;
                }

            }
            else
            {
                Client.LogManager.Log(string.Format(ToString() + " ReplyCode!=ReplyCode.OK: {0:X}", ReplyCode));

            }
        }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:35,代码来源:LoginTouchReplyPacket.cs

示例12: Read09

 /// <summary>
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read09(ByteBuffer buf)
 {
     fontFlag = buf.GetChar();
     // 分析字体属性到具体的变量
     // 字体大小
     FontSize = fontFlag & 0x1F;
     // 组体,斜体,下画线
     bold = (fontFlag & 0x20) != 0;
     italic = (fontFlag & 0x40) != 0;
     underline = (fontFlag & 0x80) != 0;
     // 字体颜色rgb
     Red = (int)buf.Get();
     Green = (int)buf.Get();
     Blue = (int)buf.Get();
     // 1个未知字节
     buf.Get();
     // 消息编码,这个据Gaim QQ的注释,这个字段用处不大,说是如果在一个英文windows
     // 里面输入了中文,那么编码是英文的,按照这个encoding来解码就不行了
     // 不过我们还是得到这个字段吧,后面我们采用先缺省GBK解码,不行就这个encoding
     // 解码,再不行就ISO-8859-1的方式
     EncodingCode = (Charset)buf.GetChar();
     Encoding = Utils.Util.GetEncodingString(EncodingCode);
     // 字体名称,字体名称也有中文的也有英文的,所以。。先来试试缺省的
     FontName = Utils.Util.GetString(buf.GetByteArray(buf.Length - buf.Position - 1));
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:28,代码来源:FontStyle.cs

示例13: Read

 /// <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;
     }
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:29,代码来源:NormalIM.cs

示例14: GetBodyBytes

 /// <summary>
 /// 得到包体的字节数组
 /// </summary>
 /// <param name="buf">The buf.</param>
 /// <param name="length">包总长度</param>
 /// <returns>包体字节数组</returns>
 protected override byte[] GetBodyBytes(ByteBuffer buf, int length)
 {
     // 得到包体长度
     int bodyLen = length - QQGlobal.QQ_LENGTH_BASIC_FAMILY_OUT_HEADER - QQGlobal.QQ_LENGTH_BASIC_FAMILY_TAIL;
     if (!user.IsUdp) bodyLen -= 2;
     // 得到加密的包体内容
     byte[] body = buf.GetByteArray(bodyLen);
     return body;
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:15,代码来源:BasicOutPacket.cs

示例15: Read

 /// <summary>
 /// 给定一个输入流,解析FileTransferArgs结构
 /// </summary>
 /// <param name="buf">The buf.</param>
 public void Read(ByteBuffer buf)
 {
     // 跳过19个无用字节
     buf.Position = buf.Position + 19;
     // 读取传输类型
     TransferType = (TransferType)buf.Get();
     // 读取连接方式
     ConnectMode = (FileConnectMode)buf.Get();
     // 读取发送者外部ip
     InternetIP = buf.GetByteArray(4);
     // 读取发送者外部端口
     InternetPort = (int)buf.GetUShort();
     // 读取文件传送端口
     if (ConnectMode != FileConnectMode.DIRECT_TCP)
         MajorPort = (int)buf.GetUShort();
     else
         MajorPort = InternetPort;
     // 读取发送者真实ip
     LocalIP = buf.GetByteArray(4);
     // 读取发送者真实端口
     MinorPort = (int)buf.GetUShort();
 }
开发者ID:leaker,项目名称:fuhj-widgets,代码行数:26,代码来源:FileTransferArgs.cs


注:本文中的System.ByteBuffer.GetByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。