.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the WebSocketPeer.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_WebSocketPeer: WebSocketPeer ============= **Inherits:** :ref:`PacketPeer` **<** :ref:`Reference` **<** :ref:`Object` **Category:** Core Brief Description ----------------- A class representing a specific WebSocket connection. Member Functions ---------------- +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`close` **(** **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_connected_host` **(** **)** const | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_connected_port` **(** **)** const | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`WriteMode` | :ref:`get_write_mode` **(** **)** const | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_connected_to_host` **(** **)** const | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_write_mode` **(** :ref:`WriteMode` mode **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`was_string_packet` **(** **)** const | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ Enums ----- .. _enum_WebSocketPeer_WriteMode: enum **WriteMode** - **WRITE_MODE_TEXT** = **0** --- Specify that WebSockets messages should be transferred as text payload (only valid UTF-8 is allowed). - **WRITE_MODE_BINARY** = **1** --- Specify that WebSockets messages should be transferred as binary payload (any byte combination is allowed). Description ----------- This class represent a specific WebSocket connection, you can do lower level operations with it. You can choose to write to the socket in binary or text mode, and you can recognize the mode used for writing by the other peer. Member Function Description --------------------------- .. _class_WebSocketPeer_close: - void **close** **(** **)** Close this WebSocket connection, actively disconnecting the peer. .. _class_WebSocketPeer_get_connected_host: - :ref:`String` **get_connected_host** **(** **)** const Returns the IP Address of the connected peer. (Not available in HTML5 export) .. _class_WebSocketPeer_get_connected_port: - :ref:`int` **get_connected_port** **(** **)** const Returns the remote port of the connected peer. (Not available in HTML5 export) .. _class_WebSocketPeer_get_write_mode: - :ref:`WriteMode` **get_write_mode** **(** **)** const Get the current selected write mode. See :ref:`WriteMode`. .. _class_WebSocketPeer_is_connected_to_host: - :ref:`bool` **is_connected_to_host** **(** **)** const Returns ``true`` if this peer is currently connected. .. _class_WebSocketPeer_set_write_mode: - void **set_write_mode** **(** :ref:`WriteMode` mode **)** Sets the socket to use the given :ref:`WriteMode`. .. _class_WebSocketPeer_was_string_packet: - :ref:`bool` **was_string_packet** **(** **)** const Returns ``true`` if the last received packet was sent as a text payload. See :ref:`WriteMode`