WebSocketServer.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="WebSocketServer" inherits="WebSocketMultiplayerPeer" category="Core" version="3.1">
  3. <brief_description>
  4. A WebSocket server implementation
  5. </brief_description>
  6. <description>
  7. This class implements a WebSocket server that can also support the high level multiplayer API.
  8. After starting the server ([method listen]), you will need to [method NetworkedMultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal.
  9. Note: This class will not work in HTML5 exports due to browser restrictions.
  10. </description>
  11. <tutorials>
  12. </tutorials>
  13. <demos>
  14. </demos>
  15. <methods>
  16. <method name="disconnect_peer">
  17. <return type="void">
  18. </return>
  19. <argument index="0" name="id" type="int">
  20. </argument>
  21. <argument index="1" name="code" type="int" default="1000">
  22. </argument>
  23. <argument index="2" name="reason" type="String" default="&quot;&quot;">
  24. </argument>
  25. <description>
  26. Disconnects the peer identified by [code]id[/code] from the server. See [method WebSocketPeer.close] for more info.
  27. </description>
  28. </method>
  29. <method name="get_peer_address" qualifiers="const">
  30. <return type="String">
  31. </return>
  32. <argument index="0" name="id" type="int">
  33. </argument>
  34. <description>
  35. Returns the IP address of the given peer.
  36. </description>
  37. </method>
  38. <method name="get_peer_port" qualifiers="const">
  39. <return type="int">
  40. </return>
  41. <argument index="0" name="id" type="int">
  42. </argument>
  43. <description>
  44. Returns the remote port of the given peer.
  45. </description>
  46. </method>
  47. <method name="has_peer" qualifiers="const">
  48. <return type="bool">
  49. </return>
  50. <argument index="0" name="id" type="int">
  51. </argument>
  52. <description>
  53. Returns [code]true[/code] if a peer with the given ID is connected.
  54. </description>
  55. </method>
  56. <method name="is_listening" qualifiers="const">
  57. <return type="bool">
  58. </return>
  59. <description>
  60. Returns [code]true[/code] if the server is actively listening on a port.
  61. </description>
  62. </method>
  63. <method name="listen">
  64. <return type="int" enum="Error">
  65. </return>
  66. <argument index="0" name="port" type="int">
  67. </argument>
  68. <argument index="1" name="protocols" type="PoolStringArray" default="PoolStringArray( )">
  69. </argument>
  70. <argument index="2" name="gd_mp_api" type="bool" default="false">
  71. </argument>
  72. <description>
  73. Start listening on the given port.
  74. You can specify the desired subprotocols via the "protocols" array. If the list empty (default), "binary" will be used.
  75. You can use this server as a network peer for [MultiplayerAPI] by passing [code]true[/code] as [code]gd_mp_api[/code]. Note: [signal data_received] will not be fired and clients other than Godot will not work in this case.
  76. </description>
  77. </method>
  78. <method name="stop">
  79. <return type="void">
  80. </return>
  81. <description>
  82. Stop the server and clear its state.
  83. </description>
  84. </method>
  85. </methods>
  86. <signals>
  87. <signal name="client_close_request">
  88. <argument index="0" name="id" type="int">
  89. </argument>
  90. <argument index="1" name="code" type="int">
  91. </argument>
  92. <argument index="2" name="reason" type="String">
  93. </argument>
  94. <description>
  95. Emitted when a client requests a clean close. You should keep polling until you get a [signal client_disconnected] signal with the same [code]id[/code] to achieve the clean close. See [method WebSocketPeer.close] for more details.
  96. </description>
  97. </signal>
  98. <signal name="client_connected">
  99. <argument index="0" name="id" type="int">
  100. </argument>
  101. <argument index="1" name="protocol" type="String">
  102. </argument>
  103. <description>
  104. Emitted when a new client connects. "protocol" will be the sub-protocol agreed with the client.
  105. </description>
  106. </signal>
  107. <signal name="client_disconnected">
  108. <argument index="0" name="id" type="int">
  109. </argument>
  110. <argument index="1" name="was_clean_close" type="bool">
  111. </argument>
  112. <description>
  113. Emitted when a client disconnects. [code]was_clean_close[/code] will be [code]true[/code] if the connection was shutdown cleanly.
  114. </description>
  115. </signal>
  116. <signal name="data_received">
  117. <argument index="0" name="id" type="int">
  118. </argument>
  119. <description>
  120. Emitted when a new message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
  121. </description>
  122. </signal>
  123. </signals>
  124. <constants>
  125. </constants>
  126. </class>