class_websocketclient.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. Properties
  13. ----------
  14. +-------------------------+-----------------------------------------------------+
  15. | :ref:`bool<class_bool>` | :ref:`verify_ssl<class_WebSocketClient_verify_ssl>` |
  16. +-------------------------+-----------------------------------------------------+
  17. Methods
  18. -------
  19. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :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 **)** |
  21. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`disconnect_from_host<class_WebSocketClient_disconnect_from_host>` **(** :ref:`int<class_int>` code=1000, :ref:`String<class_String>` reason="" **)** |
  23. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. Signals
  25. -------
  26. .. _class_WebSocketClient_connection_closed:
  27. - **connection_closed** **(** :ref:`bool<class_bool>` was_clean_close **)**
  28. Emitted when the connection to the server is closed. ``was_clean_close`` will be ``true`` if the connection was shutdown cleanly.
  29. .. _class_WebSocketClient_connection_error:
  30. - **connection_error** **(** **)**
  31. Emitted when the connection to the server fails.
  32. .. _class_WebSocketClient_connection_established:
  33. - **connection_established** **(** :ref:`String<class_String>` protocol **)**
  34. Emitted when a connection with the server is established, ``protocol`` will contain the sub-protocol agreed with the server.
  35. .. _class_WebSocketClient_data_received:
  36. - **data_received** **(** **)**
  37. Emitted when a WebSocket message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
  38. .. _class_WebSocketClient_server_close_request:
  39. - **server_close_request** **(** :ref:`int<class_int>` code, :ref:`String<class_String>` reason **)**
  40. Emitted when the server requests a clean close. You should keep polling until you get a :ref:`connection_closed<class_WebSocketClient_connection_closed>` signal to achieve the clean close. See :ref:`WebSocketPeer.close<class_WebSocketPeer_close>` for more details.
  41. Description
  42. -----------
  43. This class implements a WebSocket client compatible with any RFC 6455 complaint WebSocket server.
  44. This client can be optionally used as a network peer for the :ref:`MultiplayerAPI<class_MultiplayerAPI>`.
  45. 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>`).
  46. You will received appropriate signals when connecting, disconnecting, or when new data is available.
  47. Property Descriptions
  48. ---------------------
  49. .. _class_WebSocketClient_verify_ssl:
  50. - :ref:`bool<class_bool>` **verify_ssl**
  51. +----------+-------------------------------+
  52. | *Setter* | set_verify_ssl_enabled(value) |
  53. +----------+-------------------------------+
  54. | *Getter* | is_verify_ssl_enabled() |
  55. +----------+-------------------------------+
  56. 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.
  57. Method Descriptions
  58. -------------------
  59. .. _class_WebSocketClient_connect_to_url:
  60. - :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 **)**
  61. Connect to the given URL requesting one of the given ``protocols`` as sub-protocol.
  62. If ``true`` is passed as ``gd_mp_api``, the client will behave like a network peer for the :ref:`MultiplayerAPI<class_MultiplayerAPI>`. Note: connections to non Godot servers will not work, and :ref:`data_received<class_WebSocketClient_data_received>` will not be emitted when this option is true.
  63. .. _class_WebSocketClient_disconnect_from_host:
  64. - void **disconnect_from_host** **(** :ref:`int<class_int>` code=1000, :ref:`String<class_String>` reason="" **)**
  65. Disconnect this client from the connected host. See :ref:`WebSocketPeer.close<class_WebSocketPeer_close>` for more info.