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.

UPNPDevice

繼承: RefCounted < Object

通用隨插即用(UPnP)裝置。

說明

通用隨插即用(UPnP)裝置。UPnP 發現及工具函式見 UPNP。提供對 UPNP 控制命令的低層存取。允許管理埠對應(埠轉發)和查詢裝置的網路資訊(如本地和外部 IP 位址和狀態)。請注意,這個類的方法是同步的,會阻塞呼叫執行緒。

屬性

String

description_url

""

String

igd_control_url

""

String

igd_our_addr

""

String

igd_service_type

""

IGDStatus

igd_status

9

String

service_type

""

方法

int

add_port_mapping(port: int, port_internal: int = 0, desc: String = "", proto: String = "UDP", duration: int = 0) const

int

delete_port_mapping(port: int, proto: String = "UDP") const

bool

is_valid_gateway() const

String

query_external_address() const


列舉

enum IGDStatus: 🔗

IGDStatus IGD_STATUS_OK = 0

OK。

IGDStatus IGD_STATUS_HTTP_ERROR = 1

HTTP 錯誤。

IGDStatus IGD_STATUS_HTTP_EMPTY = 2

空的 HTTP 回應。

IGDStatus IGD_STATUS_NO_URLS = 3

已棄用: This value is no longer used.

返回的回應不包含任何 URL。

IGDStatus IGD_STATUS_NO_IGD = 4

不是有效的 IGD。

IGDStatus IGD_STATUS_DISCONNECTED = 5

已斷開連接。

IGDStatus IGD_STATUS_UNKNOWN_DEVICE = 6

未知裝置。

IGDStatus IGD_STATUS_INVALID_CONTROL = 7

無效控制。

IGDStatus IGD_STATUS_MALLOC_ERROR = 8

已棄用: This value is no longer used.

記憶體分配錯誤。

IGDStatus IGD_STATUS_UNKNOWN_ERROR = 9

未知錯誤。


屬性說明

String description_url = "" 🔗

  • void set_description_url(value: String)

  • String get_description_url()

裝置描述的 URL。


String igd_control_url = "" 🔗

  • void set_igd_control_url(value: String)

  • String get_igd_control_url()

IDG 控制項 URL。


String igd_our_addr = "" 🔗

  • void set_igd_our_addr(value: String)

  • String get_igd_our_addr()

將其連接到該 UPNPDevice 的網路中的本地機器的位址。


String igd_service_type = "" 🔗

  • void set_igd_service_type(value: String)

  • String get_igd_service_type()

IGD 服務型別。


IGDStatus igd_status = 9 🔗

IGD status.


String service_type = "" 🔗

  • void set_service_type(value: String)

  • String get_service_type()

服務型別。


方法說明

int add_port_mapping(port: int, port_internal: int = 0, desc: String = "", proto: String = "UDP", duration: int = 0) const 🔗

新增一個埠對應,將這個 UPNPDevice 上給定的外部埠轉發到本地機器上,以給定的協議。見 UPNP.add_port_mapping()


int delete_port_mapping(port: int, proto: String = "UDP") const 🔗

刪除該裝置上由給定的埠和協定組合確定的埠對應。見 UPNP.delete_port_mapping()


bool is_valid_gateway() const 🔗

如果這是一個有效的 IGD(InternetGatewayDevice),可能支援埠轉發,則返回 true


String query_external_address() const 🔗

返回這個 UPNPDevice 的外部 IP 位址或空字串。