mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
classref: Sync with current master branch (f87858a8f)
This commit is contained in:
@@ -14,217 +14,307 @@ UPNPDevice
|
||||
|
||||
Universal Plug and Play (UPnP) device.
|
||||
|
||||
.. rst-class:: classref-introduction-group
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Universal Plug and Play (UPnP) device. See :ref:`UPNP<class_UPNP>` for UPnP discovery and utility functions. Provides low-level access to UPNP control commands. Allows to manage port mappings (port forwarding) and to query network information of the device (like local and external IP address and status). Note that methods on this class are synchronous and block the calling thread.
|
||||
|
||||
.. rst-class:: classref-reftable-group
|
||||
|
||||
Properties
|
||||
----------
|
||||
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`description_url<class_UPNPDevice_property_description_url>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`igd_control_url<class_UPNPDevice_property_igd_control_url>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`igd_our_addr<class_UPNPDevice_property_igd_our_addr>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`igd_service_type<class_UPNPDevice_property_igd_service_type>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` | :ref:`igd_status<class_UPNPDevice_property_igd_status>` | ``9`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`service_type<class_UPNPDevice_property_service_type>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
.. table::
|
||||
:widths: auto
|
||||
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`description_url<class_UPNPDevice_property_description_url>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`igd_control_url<class_UPNPDevice_property_igd_control_url>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`igd_our_addr<class_UPNPDevice_property_igd_our_addr>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`igd_service_type<class_UPNPDevice_property_igd_service_type>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` | :ref:`igd_status<class_UPNPDevice_property_igd_status>` | ``9`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
| :ref:`String<class_String>` | :ref:`service_type<class_UPNPDevice_property_service_type>` | ``""`` |
|
||||
+---------------------------------------------+---------------------------------------------------------------------+--------+
|
||||
|
||||
.. rst-class:: classref-reftable-group
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`int<class_int>` | :ref:`add_port_mapping<class_UPNPDevice_method_add_port_mapping>` **(** :ref:`int<class_int>` port, :ref:`int<class_int>` port_internal=0, :ref:`String<class_String>` desc="", :ref:`String<class_String>` proto="UDP", :ref:`int<class_int>` duration=0 **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`int<class_int>` | :ref:`delete_port_mapping<class_UPNPDevice_method_delete_port_mapping>` **(** :ref:`int<class_int>` port, :ref:`String<class_String>` proto="UDP" **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`is_valid_gateway<class_UPNPDevice_method_is_valid_gateway>` **(** **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`String<class_String>` | :ref:`query_external_address<class_UPNPDevice_method_query_external_address>` **(** **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
.. table::
|
||||
:widths: auto
|
||||
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`int<class_int>` | :ref:`add_port_mapping<class_UPNPDevice_method_add_port_mapping>` **(** :ref:`int<class_int>` port, :ref:`int<class_int>` port_internal=0, :ref:`String<class_String>` desc="", :ref:`String<class_String>` proto="UDP", :ref:`int<class_int>` duration=0 **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`int<class_int>` | :ref:`delete_port_mapping<class_UPNPDevice_method_delete_port_mapping>` **(** :ref:`int<class_int>` port, :ref:`String<class_String>` proto="UDP" **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`is_valid_gateway<class_UPNPDevice_method_is_valid_gateway>` **(** **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`String<class_String>` | :ref:`query_external_address<class_UPNPDevice_method_query_external_address>` **(** **)** |const| |
|
||||
+-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
----
|
||||
|
||||
.. rst-class:: classref-descriptions-group
|
||||
|
||||
Enumerations
|
||||
------------
|
||||
|
||||
.. _enum_UPNPDevice_IGDStatus:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_OK:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_HTTP_ERROR:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_HTTP_EMPTY:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_NO_URLS:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_NO_IGD:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_DISCONNECTED:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_UNKNOWN_DEVICE:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_INVALID_CONTROL:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_MALLOC_ERROR:
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_UNKNOWN_ERROR:
|
||||
.. rst-class:: classref-enumeration
|
||||
|
||||
enum **IGDStatus**:
|
||||
|
||||
- **IGD_STATUS_OK** = **0** --- OK.
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_OK:
|
||||
|
||||
- **IGD_STATUS_HTTP_ERROR** = **1** --- HTTP error.
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
- **IGD_STATUS_HTTP_EMPTY** = **2** --- Empty HTTP response.
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_OK** = ``0``
|
||||
|
||||
- **IGD_STATUS_NO_URLS** = **3** --- Returned response contained no URLs.
|
||||
OK.
|
||||
|
||||
- **IGD_STATUS_NO_IGD** = **4** --- Not a valid IGD.
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_HTTP_ERROR:
|
||||
|
||||
- **IGD_STATUS_DISCONNECTED** = **5** --- Disconnected.
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
- **IGD_STATUS_UNKNOWN_DEVICE** = **6** --- Unknown device.
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_HTTP_ERROR** = ``1``
|
||||
|
||||
- **IGD_STATUS_INVALID_CONTROL** = **7** --- Invalid control.
|
||||
HTTP error.
|
||||
|
||||
- **IGD_STATUS_MALLOC_ERROR** = **8** --- Memory allocation error.
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_HTTP_EMPTY:
|
||||
|
||||
- **IGD_STATUS_UNKNOWN_ERROR** = **9** --- Unknown error.
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_HTTP_EMPTY** = ``2``
|
||||
|
||||
Empty HTTP response.
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_NO_URLS:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_NO_URLS** = ``3``
|
||||
|
||||
Returned response contained no URLs.
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_NO_IGD:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_NO_IGD** = ``4``
|
||||
|
||||
Not a valid IGD.
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_DISCONNECTED:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_DISCONNECTED** = ``5``
|
||||
|
||||
Disconnected.
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_UNKNOWN_DEVICE:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_UNKNOWN_DEVICE** = ``6``
|
||||
|
||||
Unknown device.
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_INVALID_CONTROL:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_INVALID_CONTROL** = ``7``
|
||||
|
||||
Invalid control.
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_MALLOC_ERROR:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_MALLOC_ERROR** = ``8``
|
||||
|
||||
Memory allocation error.
|
||||
|
||||
.. _class_UPNPDevice_constant_IGD_STATUS_UNKNOWN_ERROR:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **IGD_STATUS_UNKNOWN_ERROR** = ``9``
|
||||
|
||||
Unknown error.
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
----
|
||||
|
||||
.. rst-class:: classref-descriptions-group
|
||||
|
||||
Property Descriptions
|
||||
---------------------
|
||||
|
||||
.. _class_UPNPDevice_property_description_url:
|
||||
|
||||
- :ref:`String<class_String>` **description_url**
|
||||
.. rst-class:: classref-property
|
||||
|
||||
+-----------+----------------------------+
|
||||
| *Default* | ``""`` |
|
||||
+-----------+----------------------------+
|
||||
| *Setter* | set_description_url(value) |
|
||||
+-----------+----------------------------+
|
||||
| *Getter* | get_description_url() |
|
||||
+-----------+----------------------------+
|
||||
:ref:`String<class_String>` **description_url** = ``""``
|
||||
|
||||
.. rst-class:: classref-property-setget
|
||||
|
||||
- void **set_description_url** **(** :ref:`String<class_String>` value **)**
|
||||
- :ref:`String<class_String>` **get_description_url** **(** **)**
|
||||
|
||||
URL to the device description.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_property_igd_control_url:
|
||||
|
||||
- :ref:`String<class_String>` **igd_control_url**
|
||||
.. rst-class:: classref-property
|
||||
|
||||
+-----------+----------------------------+
|
||||
| *Default* | ``""`` |
|
||||
+-----------+----------------------------+
|
||||
| *Setter* | set_igd_control_url(value) |
|
||||
+-----------+----------------------------+
|
||||
| *Getter* | get_igd_control_url() |
|
||||
+-----------+----------------------------+
|
||||
:ref:`String<class_String>` **igd_control_url** = ``""``
|
||||
|
||||
.. rst-class:: classref-property-setget
|
||||
|
||||
- void **set_igd_control_url** **(** :ref:`String<class_String>` value **)**
|
||||
- :ref:`String<class_String>` **get_igd_control_url** **(** **)**
|
||||
|
||||
IDG control URL.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_property_igd_our_addr:
|
||||
|
||||
- :ref:`String<class_String>` **igd_our_addr**
|
||||
.. rst-class:: classref-property
|
||||
|
||||
+-----------+-------------------------+
|
||||
| *Default* | ``""`` |
|
||||
+-----------+-------------------------+
|
||||
| *Setter* | set_igd_our_addr(value) |
|
||||
+-----------+-------------------------+
|
||||
| *Getter* | get_igd_our_addr() |
|
||||
+-----------+-------------------------+
|
||||
:ref:`String<class_String>` **igd_our_addr** = ``""``
|
||||
|
||||
Address of the local machine in the network connecting it to this ``UPNPDevice``.
|
||||
.. rst-class:: classref-property-setget
|
||||
|
||||
- void **set_igd_our_addr** **(** :ref:`String<class_String>` value **)**
|
||||
- :ref:`String<class_String>` **get_igd_our_addr** **(** **)**
|
||||
|
||||
Address of the local machine in the network connecting it to this **UPNPDevice**.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_property_igd_service_type:
|
||||
|
||||
- :ref:`String<class_String>` **igd_service_type**
|
||||
.. rst-class:: classref-property
|
||||
|
||||
+-----------+-----------------------------+
|
||||
| *Default* | ``""`` |
|
||||
+-----------+-----------------------------+
|
||||
| *Setter* | set_igd_service_type(value) |
|
||||
+-----------+-----------------------------+
|
||||
| *Getter* | get_igd_service_type() |
|
||||
+-----------+-----------------------------+
|
||||
:ref:`String<class_String>` **igd_service_type** = ``""``
|
||||
|
||||
.. rst-class:: classref-property-setget
|
||||
|
||||
- void **set_igd_service_type** **(** :ref:`String<class_String>` value **)**
|
||||
- :ref:`String<class_String>` **get_igd_service_type** **(** **)**
|
||||
|
||||
IGD service type.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_property_igd_status:
|
||||
|
||||
- :ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **igd_status**
|
||||
.. rst-class:: classref-property
|
||||
|
||||
+-----------+-----------------------+
|
||||
| *Default* | ``9`` |
|
||||
+-----------+-----------------------+
|
||||
| *Setter* | set_igd_status(value) |
|
||||
+-----------+-----------------------+
|
||||
| *Getter* | get_igd_status() |
|
||||
+-----------+-----------------------+
|
||||
:ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **igd_status** = ``9``
|
||||
|
||||
.. rst-class:: classref-property-setget
|
||||
|
||||
- void **set_igd_status** **(** :ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` value **)**
|
||||
- :ref:`IGDStatus<enum_UPNPDevice_IGDStatus>` **get_igd_status** **(** **)**
|
||||
|
||||
IGD status. See :ref:`IGDStatus<enum_UPNPDevice_IGDStatus>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_property_service_type:
|
||||
|
||||
- :ref:`String<class_String>` **service_type**
|
||||
.. rst-class:: classref-property
|
||||
|
||||
+-----------+-------------------------+
|
||||
| *Default* | ``""`` |
|
||||
+-----------+-------------------------+
|
||||
| *Setter* | set_service_type(value) |
|
||||
+-----------+-------------------------+
|
||||
| *Getter* | get_service_type() |
|
||||
+-----------+-------------------------+
|
||||
:ref:`String<class_String>` **service_type** = ``""``
|
||||
|
||||
.. rst-class:: classref-property-setget
|
||||
|
||||
- void **set_service_type** **(** :ref:`String<class_String>` value **)**
|
||||
- :ref:`String<class_String>` **get_service_type** **(** **)**
|
||||
|
||||
Service type.
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
----
|
||||
|
||||
.. rst-class:: classref-descriptions-group
|
||||
|
||||
Method Descriptions
|
||||
-------------------
|
||||
|
||||
.. _class_UPNPDevice_method_add_port_mapping:
|
||||
|
||||
- :ref:`int<class_int>` **add_port_mapping** **(** :ref:`int<class_int>` port, :ref:`int<class_int>` port_internal=0, :ref:`String<class_String>` desc="", :ref:`String<class_String>` proto="UDP", :ref:`int<class_int>` duration=0 **)** |const|
|
||||
.. rst-class:: classref-method
|
||||
|
||||
Adds a port mapping to forward the given external port on this ``UPNPDevice`` for the given protocol to the local machine. See :ref:`UPNP.add_port_mapping<class_UPNP_method_add_port_mapping>`.
|
||||
:ref:`int<class_int>` **add_port_mapping** **(** :ref:`int<class_int>` port, :ref:`int<class_int>` port_internal=0, :ref:`String<class_String>` desc="", :ref:`String<class_String>` proto="UDP", :ref:`int<class_int>` duration=0 **)** |const|
|
||||
|
||||
Adds a port mapping to forward the given external port on this **UPNPDevice** for the given protocol to the local machine. See :ref:`UPNP.add_port_mapping<class_UPNP_method_add_port_mapping>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_method_delete_port_mapping:
|
||||
|
||||
- :ref:`int<class_int>` **delete_port_mapping** **(** :ref:`int<class_int>` port, :ref:`String<class_String>` proto="UDP" **)** |const|
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`int<class_int>` **delete_port_mapping** **(** :ref:`int<class_int>` port, :ref:`String<class_String>` proto="UDP" **)** |const|
|
||||
|
||||
Deletes the port mapping identified by the given port and protocol combination on this device. See :ref:`UPNP.delete_port_mapping<class_UPNP_method_delete_port_mapping>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_method_is_valid_gateway:
|
||||
|
||||
- :ref:`bool<class_bool>` **is_valid_gateway** **(** **)** |const|
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`bool<class_bool>` **is_valid_gateway** **(** **)** |const|
|
||||
|
||||
Returns ``true`` if this is a valid IGD (InternetGatewayDevice) which potentially supports port forwarding.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_UPNPDevice_method_query_external_address:
|
||||
|
||||
- :ref:`String<class_String>` **query_external_address** **(** **)** |const|
|
||||
.. rst-class:: classref-method
|
||||
|
||||
Returns the external IP address of this ``UPNPDevice`` or an empty string.
|
||||
:ref:`String<class_String>` **query_external_address** **(** **)** |const|
|
||||
|
||||
Returns the external IP address of this **UPNPDevice** or an empty string.
|
||||
|
||||
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
||||
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
||||
|
||||
Reference in New Issue
Block a user