• <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參數(shù)為0時并非是讀0個字節(jié)

            2016-07-03 日更新 此篇博客已經(jīng)遷移到新博客,并做行文檢查和優(yōu)化排版:


            一、官方文檔注解如下:
            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.
            二、參數(shù)注意
            第3個參數(shù)length,如果傳0表示將ByteArray里的剩余數(shù)據(jù)全部讀進bytes里,與通常的API理解不一致。
            這點有點怪異,我的程序里,ByteArray類型的buff需要從ByteArray類型的recvBuff里讀取給定數(shù)量的字節(jié)數(shù)。字節(jié)數(shù)有可能是0(protobuf里,如果全為optional字段,并且沒有設定值,這個protobuf協(xié)議序列化的結果就是0字節(jié)),企圖用recvBuff.readBytes(buff, 0, 0)來讀取零字節(jié)是不能達到目的的。
            recvBuff里還有其他的網(wǎng)絡包數(shù)據(jù),如果用readBytes(buff, 0, 0)會把recvBuff里其他網(wǎng)絡包的數(shù)據(jù)讀給了當前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年10月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統(tǒng)計

            留言簿(1)

            隨筆分類(77)

            隨筆檔案(58)

            me

            基友

            同行

            業(yè)界前輩

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久一本综合| 久久久久人妻一区精品| 久久777国产线看观看精品| 99久久国产免费福利| 久久精品极品盛宴观看| 青青草原综合久久| 久久青青草原精品国产| 99久久国产综合精品网成人影院| 亚洲精品第一综合99久久| 99久久精品费精品国产 | 亚洲日本va午夜中文字幕久久| 久久久久99精品成人片欧美| 日韩亚洲国产综合久久久| 香蕉久久夜色精品国产小说| 97久久超碰国产精品2021| 久久精品国产亚洲av麻豆色欲 | 国产亚洲欧美精品久久久| 亚洲国产美女精品久久久久∴ | 久久无码高潮喷水| 国内精品久久人妻互换| 99久久精品国产免看国产一区| 久久亚洲AV成人无码软件| 久久久久se色偷偷亚洲精品av | 亚洲国产成人久久综合一区77 | 精品久久无码中文字幕| 狠狠色丁香婷婷久久综合不卡| 国产精品禁18久久久夂久| 久久精品成人欧美大片| 国产成人精品综合久久久久| 久久精品www人人爽人人| 久久精品极品盛宴观看| 91精品久久久久久无码| 久久人妻少妇嫩草AV蜜桃| 欧美亚洲色综久久精品国产| 亚洲欧美另类日本久久国产真实乱对白| 久久精品蜜芽亚洲国产AV| 一级做a爰片久久毛片免费陪| 99久久超碰中文字幕伊人| 国产偷久久久精品专区| 久久天天婷婷五月俺也去| 久久青青草原精品国产软件|