Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

StreamPeerBuffer

繼承: StreamPeer < RefCounted < Object

用於處理二進位資料流的流對等體。

說明

使用位元組陣列作為流的資料緩衝區流對等體。該物件可用於處理來自網路會話的二進位資料。要處理保存在檔中的二進位資料,可以直接使用 FileAccess

StreamPeerBuffer 物件會保存一個內部指標,是距離該緩衝區開頭的位元組偏移量。Get 和 put 操作都在該指標處進行,並會將其進行對應的移動。

屬性

PackedByteArray

data_array

PackedByteArray()

方法

void

clear()

StreamPeerBuffer

duplicate() const

int

get_position() const

int

get_size() const

void

resize(size: int)

void

seek(position: int)


屬性說明

PackedByteArray data_array = PackedByteArray() 🔗

內部的資料緩衝。設定該值會重設指針。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedByteArray for more details.


方法說明

void clear() 🔗

清除 data_array 並重設指針。


StreamPeerBuffer duplicate() const 🔗

返回新的 StreamPeerBuffer,具有相同的 data_array 內容。


int get_position() const 🔗

返回目前的指針位置。


int get_size() const 🔗

返回 data_array 的大小。


void resize(size: int) 🔗

調整 data_array 的大小。不會更新指針。


void seek(position: int) 🔗

將指標移動到指定的位置。position 必須是 data_array 的有效索引。