• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Sheppard Y

            keep thinking keep coding.

            as3里ByteArray的readBytes方法length參數為0時并非是讀0個字節

            2016-07-03 日更新 此篇博客已經遷移到新博客,并做行文檢查和優化排版:


            一、官方文檔注解如下:
            public function readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
            Reads the number of data bytes, specified by the length parameter, from the byte stream. The bytes are read into the ByteArray object specified by the bytes parameter, and the bytes are written into the destination ByteArray starting at the position specified by offset.
            Parameters
            bytes:ByteArray — The ByteArray object to read data into. 
            offset:uint (default = 0) — The offset (position) in bytes at which the read data should be written. 
            length:uint (default = 0) — The number of bytes to read. The default value of 0 causes all available data to be read.
            二、參數注意
            第3個參數length,如果傳0表示將ByteArray里的剩余數據全部讀進bytes里,與通常的API理解不一致。
            這點有點怪異,我的程序里,ByteArray類型的buff需要從ByteArray類型的recvBuff里讀取給定數量的字節數。字節數有可能是0(protobuf里,如果全為optional字段,并且沒有設定值,這個protobuf協議序列化的結果就是0字節),企圖用recvBuff.readBytes(buff, 0, 0)來讀取零字節是不能達到目的的。
            recvBuff里還有其他的網絡包數據,如果用readBytes(buff, 0, 0)會把recvBuff里其他網絡包的數據讀給了當前buff,然后交給當前包對應的protobuf類來反序列化,就錯了。
            癥狀如下,方便大家搜索到此文:
            Bad data format: **.** cannot be set twice.
            invalid nested message
            message length = 1
            注:as3, protobuf-gen-as3(http://code.google.com/p/protoc-gen-as3/)

            ps:2012年9月19日我在CU上的博文

            posted on 2013-04-08 17:54 Sheppard Y 閱讀(2128) 評論(0)  編輯 收藏 引用 所屬分類: 其他語言

            <2013年4月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            導航

            統計

            留言簿(1)

            隨筆分類(77)

            隨筆檔案(58)

            me

            基友

            同行

            業界前輩

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久综合精品国产二区无码| 久久国产高清字幕中文| 久久高潮一级毛片免费| 亚洲日韩欧美一区久久久久我| 久久香综合精品久久伊人| 国产成人精品久久免费动漫| 久久伊人色| 国产精品无码久久久久久| 久久久久人妻一区精品| 97久久超碰国产精品旧版| 色偷偷91久久综合噜噜噜噜| 狠色狠色狠狠色综合久久| 久久久亚洲裙底偷窥综合| 久久久久国产| 国产99久久久国产精品~~牛| 久久精品国产亚洲av麻豆蜜芽| 久久精品国产精品亚洲| www久久久天天com| 久久亚洲中文字幕精品有坂深雪| 久久香蕉国产线看观看猫咪?v| 青青青国产精品国产精品久久久久 | 人妻精品久久久久中文字幕69| 久久久久一级精品亚洲国产成人综合AV区| 亚洲国产成人久久综合区| 丁香五月综合久久激情| 狠狠色丁香婷婷久久综合不卡| 久久99精品久久久久久久久久| 亚洲精品无码久久一线| 亚洲午夜无码久久久久| 久久久久亚洲AV无码专区首JN| 久久无码AV中文出轨人妻| 久久精品二区| 无码任你躁久久久久久老妇| 国产精品久久久天天影视香蕉| 国产L精品国产亚洲区久久| 久久精品国产只有精品2020| 国产美女久久久| 丁香五月综合久久激情| 久久精品国产福利国产琪琪| 久久天天躁狠狠躁夜夜av浪潮 | 中文字幕人妻色偷偷久久|