• <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ù)全部讀進(jìn)bytes里,與通常的API理解不一致。
            這點(diǎn)有點(diǎn)怪異,我的程序里,ByteArray類型的buff需要從ByteArray類型的recvBuff里讀取給定數(shù)量的字節(jié)數(shù)。字節(jié)數(shù)有可能是0(protobuf里,如果全為optional字段,并且沒有設(shè)定值,這個protobuf協(xié)議序列化的結(jié)果就是0字節(jié)),企圖用recvBuff.readBytes(buff, 0, 0)來讀取零字節(jié)是不能達(dá)到目的的。
            recvBuff里還有其他的網(wǎng)絡(luò)包數(shù)據(jù),如果用readBytes(buff, 0, 0)會把recvBuff里其他網(wǎng)絡(luò)包的數(shù)據(jù)讀給了當(dāng)前buff,然后交給當(dāng)前包對應(yīng)的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)  編輯 收藏 引用 所屬分類: 其他語言

            <2008年12月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            導(dǎo)航

            統(tǒng)計

            留言簿(1)

            隨筆分類(77)

            隨筆檔案(58)

            me

            基友

            同行

            業(yè)界前輩

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            婷婷久久精品国产| 97精品久久天干天天天按摩| 青青草国产精品久久久久| 国产精品久久久久久久久免费 | 亚洲午夜久久久久久噜噜噜| 精品一二三区久久aaa片| 久久精品无码一区二区无码| 国产成人精品久久一区二区三区 | 色综合久久夜色精品国产| 亚洲人成网亚洲欧洲无码久久| 久久大香香蕉国产| 热综合一本伊人久久精品| 亚洲日本va中文字幕久久| 99久久99久久精品国产片| 蜜桃麻豆WWW久久囤产精品| 91精品国产乱码久久久久久| 久久久久黑人强伦姧人妻| 无码AV中文字幕久久专区| 久久婷婷五月综合97色直播| 久久久免费精品re6| 人人妻久久人人澡人人爽人人精品 | 国产精品久久自在自线观看| 久久笫一福利免费导航 | 国内精品人妻无码久久久影院导航| 97久久精品午夜一区二区| 亚洲&#228;v永久无码精品天堂久久| 无码精品久久久天天影视 | 久久精品中文字幕无码绿巨人| 狠狠综合久久综合中文88| 99久久免费国产精品热| 一本色道久久综合亚洲精品| 国产99久久久国产精品~~牛| 国产午夜免费高清久久影院| 欧美日韩精品久久久免费观看 | 久久精品国产99国产精品亚洲| 久久精品一区二区影院| 精品多毛少妇人妻AV免费久久| 久久天堂电影网| 国产精品激情综合久久| 狠狠色噜噜狠狠狠狠狠色综合久久| 久久久国产精品亚洲一区|