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...
StreamPeerTLS
繼承: StreamPeer < RefCounted < Object
處理 TLS 連接的流對等體。
說明
處理 TLS 連接的流對等體。此物件可用於連接到 TLS 伺服器或接受單個 TLS 使用者端連接。
注意:當匯出到 Android 時,確保在匯出專案或使用一鍵部署之前,在 Android 匯出預設中啟用 INTERNET 許可權。否則,任何形式的網路通信都會被 Android 阻止。
教學
方法
accept_stream(stream: StreamPeer, server_options: TLSOptions) |
|
connect_to_stream(stream: StreamPeer, common_name: String, client_options: TLSOptions = null) |
|
void |
|
get_status() const |
|
get_stream() const |
|
void |
poll() |
列舉
enum Status: 🔗
Status STATUS_DISCONNECTED = 0
狀態,表示 StreamPeerTLS 已斷開連接。
Status STATUS_HANDSHAKING = 1
狀態,表示 StreamPeerTLS 處於握手階段。
Status STATUS_CONNECTED = 2
狀態,表示 StreamPeerTLS 已連接至主機。
Status STATUS_ERROR = 3
狀態,表示 StreamPeerTLS 處於出錯狀態。
Status STATUS_ERROR_HOSTNAME_MISMATCH = 4
錯誤狀態,表示主機的 TLS 憑證功能變數名稱與請求驗證的功能變數名稱不配對。
方法說明
Error accept_stream(stream: StreamPeer, server_options: TLSOptions) 🔗
以伺服器的身份接受對等體連接,使用給定的伺服器選項 server_options。見 TLSOptions.server()。
Error connect_to_stream(stream: StreamPeer, common_name: String, client_options: TLSOptions = null) 🔗
使用底層 StreamPeer stream 連接到對等體,並對遠端憑證是否由給定的 common_name 簽章進行驗證。傳入 client_options 可以自訂信任的憑證授權,也可以禁用通用名稱驗證。見 TLSOptions.client() 和 TLSOptions.client_unsafe()。
void disconnect_from_stream() 🔗
與主機斷開連接。
Returns the status of the connection.
StreamPeer get_stream() const 🔗
返回底層 StreamPeer 連接,在 accept_stream() 或 connect_to_stream() 中使用。
void poll() 🔗
輪詢連接以檢查傳入的位元組。在 StreamPeer.get_available_bytes() 之前呼叫它以使其正常工作。