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.
Checking the stable version of the documentation...
StreamPeerGZIP
實驗性: This class may be changed or removed in future versions.
繼承: StreamPeer < RefCounted < Object
能夠處理 GZIP 和 deflate 壓縮/解壓縮的流對等體。
說明
這個類能夠使用 GZIP/deflate 對資料進行流式壓縮或解壓縮。壓縮或解壓縮經過網路發送的檔時尤其有用,不必事先分配記憶體。
使用 start_compression()(或 start_decompression())開啟流之後,在這個流上呼叫 StreamPeer.put_partial_data() 會對資料進行壓縮(或解壓縮)並寫入內部緩衝區。呼叫 StreamPeer.get_available_bytes() 會返回內部緩衝區中待處理的位元組數,StreamPeer.get_partial_data() 會從中獲取壓縮後(或解壓後)的位元組。流結束後,你必須呼叫 finish() 來確保正確清空內部緩衝區(請務必最後再呼叫一次 StreamPeer.get_available_bytes(),檢查此時是否還有需要讀取的資料)。
方法
void |
clear() |
finish() |
|
start_compression(use_deflate: bool = false, buffer_size: int = 65535) |
|
start_decompression(use_deflate: bool = false, buffer_size: int = 65535) |
方法說明
void clear() 🔗
清空該流,重設內部狀態。
Finalizes the stream, compressing any buffered chunk left.
You must call it only when you are compressing.
Error start_compression(use_deflate: bool = false, buffer_size: int = 65535) 🔗
開始壓縮模式的流,緩衝區大小為 buffer_size,如果 use_deflate 為 true 則使用 deflate 而不是 GZIP。
Error start_decompression(use_deflate: bool = false, buffer_size: int = 65535) 🔗
開始解壓模式的流,緩衝區大小為 buffer_size,如果 use_deflate 為 true 則使用 deflate 而不是 GZIP。