• <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

            基友

            同行

            業界前輩

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久毛片免费看一区二区三区| 日日躁夜夜躁狠狠久久AV| 久久综合久久自在自线精品自| 久久亚洲春色中文字幕久久久| 国产成人久久精品区一区二区| 亚洲国产精品久久久久婷婷软件| 伊人久久综合热线大杳蕉下载| 香蕉久久永久视频| 国产精品久久久福利| 色天使久久综合网天天| 亚洲va久久久噜噜噜久久男同 | 久久亚洲精品成人AV| 久久综合综合久久97色| 久久人妻少妇嫩草AV蜜桃| 热久久国产精品| 久久精品亚洲一区二区三区浴池 | 理论片午午伦夜理片久久| 国产免费久久精品99re丫y| 国产午夜久久影院| 亚洲国产精品无码久久98| 久久国产免费直播| 久久亚洲精品无码aⅴ大香| 久久国产精品99精品国产987| 精品熟女少妇AV免费久久| 99久久精品免费观看国产| 国产精品久久午夜夜伦鲁鲁| 漂亮人妻被中出中文字幕久久| 久久99精品久久久久久噜噜| 久久这里只精品国产99热| 国内精品久久人妻互换| 久久亚洲欧美国产精品| 亚洲第一极品精品无码久久| 久久人人爽人人爽人人片AV高清| 欧洲性大片xxxxx久久久| 久久久综合香蕉尹人综合网| 精品久久久久中文字幕一区| 日本一区精品久久久久影院| 久久精品国产影库免费看| 热久久这里只有精品| 久久久久99精品成人片| 亚洲人成无码www久久久|