當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。