• <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è)界前輩

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            狠狠色丁香婷综合久久| 亚洲国产高清精品线久久| 久久久噜噜噜久久熟女AA片| 色狠狠久久AV五月综合| 久久久久久久99精品免费观看| 亚洲国产精品久久久久婷婷老年 | 尹人香蕉久久99天天拍| 亚洲综合日韩久久成人AV| 国产人久久人人人人爽| 午夜精品久久久久久| 国产成人综合久久综合| 无码人妻久久一区二区三区蜜桃| 香蕉久久夜色精品国产小说| 亚洲欧美国产精品专区久久| 国产美女久久精品香蕉69| 中文精品99久久国产| 久久综合久久久| 嫩草伊人久久精品少妇AV| 理论片午午伦夜理片久久 | 伊人久久大香线蕉AV色婷婷色| 久久电影网一区| 国产色综合久久无码有码| 国产成人精品久久综合| 久久久久亚洲av无码专区| 久久综合亚洲色HEZYO社区| 色综合合久久天天给综看| 国产成人99久久亚洲综合精品| 精品久久久久久成人AV| 久久亚洲精品无码AV红樱桃| 99久久无色码中文字幕人妻| 久久这里都是精品| 国产精品久久久久免费a∨| 日产久久强奸免费的看| 欧美粉嫩小泬久久久久久久 | 亚洲欧美精品伊人久久| 久久99国产精品尤物| 国产∨亚洲V天堂无码久久久| 久久久久无码精品国产不卡| 色欲久久久天天天综合网| 亚洲va久久久噜噜噜久久| 亚洲AV无一区二区三区久久|