class_websocketclient.rst 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the WebSocketClient.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_WebSocketClient:
  5. WebSocketClient
  6. ===============
  7. **Inherits:** :ref:`WebSocketMultiplayerPeer<class_websocketmultiplayerpeer>` **<** :ref:`NetworkedMultiplayerPeer<class_networkedmultiplayerpeer>` **<** :ref:`PacketPeer<class_packetpeer>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. A WebSocket client implementation
  12. Member Functions
  13. ----------------
  14. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`Error<enum_@globalscope_error>` | :ref:`connect_to_url<class_WebSocketClient_connect_to_url>` **(** :ref:`String<class_string>` url, :ref:`PoolStringArray<class_poolstringarray>` protocols=PoolStringArray( ), :ref:`bool<class_bool>` gd_mp_api=false **)** |
  16. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`disconnect_from_host<class_WebSocketClient_disconnect_from_host>` **(** **)** |
  18. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. Signals
  20. -------
  21. .. _class_WebSocketClient_connection_closed:
  22. - **connection_closed** **(** **)**
  23. Emitted when the connection to the server is closed.
  24. .. _class_WebSocketClient_connection_error:
  25. - **connection_error** **(** **)**
  26. Emitted when the connection to the server fails.
  27. .. _class_WebSocketClient_connection_established:
  28. - **connection_established** **(** :ref:`String<class_string>` protocol **)**
  29. Emitted when a connection with the server is established, ``protocol`` will contain the sub-protocol agreed with the server.
  30. .. _class_WebSocketClient_data_received:
  31. - **data_received** **(** **)**
  32. Emitted when a WebSocket message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
  33. Member Variables
  34. ----------------
  35. .. _class_WebSocketClient_verify_ssl:
  36. - :ref:`bool<class_bool>` **verify_ssl** - Enable or disable SSL certificate verification. Note: You must specify the certificates to be used in the project settings for it to work when exported.
  37. Description
  38. -----------
  39. This class implements a WebSocket client compatible with any RFC 6455 complaint WebSocket server.
  40. This client can be optionally used as a network peer for the :ref:`MultiplayerAPI<class_multiplayerapi>`.
  41. After starting the client (:ref:`connect_to_url<class_WebSocketClient_connect_to_url>`), you will need to :ref:`NetworkedMultiplayerPeer.poll<class_NetworkedMultiplayerPeer_poll>` it at regular intervals (e.g. inside :ref:`Node._process<class_Node__process>`).
  42. You will received appropriate signals when connecting, disconnecting, or when new data is available.
  43. Member Function Description
  44. ---------------------------
  45. .. _class_WebSocketClient_connect_to_url:
  46. - :ref:`Error<enum_@globalscope_error>` **connect_to_url** **(** :ref:`String<class_string>` url, :ref:`PoolStringArray<class_poolstringarray>` protocols=PoolStringArray( ), :ref:`bool<class_bool>` gd_mp_api=false **)**
  47. Connect to the given URL requesting one of the given ``protocols`` as sub-protocol.
  48. If ``true`` is passed as ``gd_mp_api``, the client will behave like a network peer for the :ref:`MultiplayerAPI<class_multiplayerapi>`. Note: connnections to non Godot servers will not work, and :ref:`data_received<class_WebSocketClient_data_received>` will not be emitted when this option is true.
  49. .. _class_WebSocketClient_disconnect_from_host:
  50. - void **disconnect_from_host** **(** **)**
  51. Disconnect from the server if currently connected.