WebSocketClient.xml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="WebSocketClient" inherits="WebSocketMultiplayerPeer" category="Core" version="3.1">
  3. <brief_description>
  4. A WebSocket client implementation
  5. </brief_description>
  6. <description>
  7. This class implements a WebSocket client compatible with any RFC 6455 complaint WebSocket server.
  8. This client can be optionally used as a network peer for the [MultiplayerAPI].
  9. After starting the client ([method connect_to_url]), you will need to [method NetworkedMultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]).
  10. You will received appropriate signals when connecting, disconnecting, or when new data is available.
  11. </description>
  12. <tutorials>
  13. </tutorials>
  14. <demos>
  15. </demos>
  16. <methods>
  17. <method name="connect_to_url">
  18. <return type="int" enum="Error">
  19. </return>
  20. <argument index="0" name="url" type="String">
  21. </argument>
  22. <argument index="1" name="protocols" type="PoolStringArray" default="PoolStringArray( )">
  23. </argument>
  24. <argument index="2" name="gd_mp_api" type="bool" default="false">
  25. </argument>
  26. <description>
  27. Connect to the given URL requesting one of the given [code]protocols[/code] as sub-protocol.
  28. If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a network peer for the [MultiplayerAPI], connections to non Godot servers will not work, and [signal data_received] will not be emitted.
  29. If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.) on the [WebSocketPeer] returned via [code]get_peer(1)[/code] and not on this object directly (e.g. [code]get_peer(1).put_packet(data)[/code]).
  30. </description>
  31. </method>
  32. <method name="disconnect_from_host">
  33. <return type="void">
  34. </return>
  35. <argument index="0" name="code" type="int" default="1000">
  36. </argument>
  37. <argument index="1" name="reason" type="String" default="&quot;&quot;">
  38. </argument>
  39. <description>
  40. Disconnect this client from the connected host. See [method WebSocketPeer.close] for more info.
  41. </description>
  42. </method>
  43. </methods>
  44. <members>
  45. <member name="verify_ssl" type="bool" setter="set_verify_ssl_enabled" getter="is_verify_ssl_enabled">
  46. 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.
  47. </member>
  48. </members>
  49. <signals>
  50. <signal name="connection_closed">
  51. <argument index="0" name="was_clean_close" type="bool">
  52. </argument>
  53. <description>
  54. Emitted when the connection to the server is closed. [code]was_clean_close[/code] will be [code]true[/code] if the connection was shutdown cleanly.
  55. </description>
  56. </signal>
  57. <signal name="connection_error">
  58. <description>
  59. Emitted when the connection to the server fails.
  60. </description>
  61. </signal>
  62. <signal name="connection_established">
  63. <argument index="0" name="protocol" type="String">
  64. </argument>
  65. <description>
  66. Emitted when a connection with the server is established, [code]protocol[/code] will contain the sub-protocol agreed with the server.
  67. </description>
  68. </signal>
  69. <signal name="data_received">
  70. <description>
  71. Emitted when a WebSocket message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
  72. </description>
  73. </signal>
  74. <signal name="server_close_request">
  75. <argument index="0" name="code" type="int">
  76. </argument>
  77. <argument index="1" name="reason" type="String">
  78. </argument>
  79. <description>
  80. Emitted when the server requests a clean close. You should keep polling until you get a [signal connection_closed] signal to achieve the clean close. See [method WebSocketPeer.close] for more details.
  81. </description>
  82. </signal>
  83. </signals>
  84. <constants>
  85. </constants>
  86. </class>