Update WebSocket documentation

This commit is contained in:
Fabio Alessandrelli 2018-09-24 01:49:09 +02:00
parent 4b92956db7
commit df43b94e6e
3 changed files with 44 additions and 6 deletions

View File

@ -31,8 +31,12 @@
<method name="disconnect_from_host"> <method name="disconnect_from_host">
<return type="void"> <return type="void">
</return> </return>
<argument index="0" name="code" type="int" default="1000">
</argument>
<argument index="1" name="reason" type="String" default="&quot;&quot;">
</argument>
<description> <description>
Disconnect from the server if currently connected. Disconnect this client from the connected host. See [method WebSocketPeer.close] for more info.
</description> </description>
</method> </method>
</methods> </methods>
@ -43,8 +47,10 @@
</members> </members>
<signals> <signals>
<signal name="connection_closed"> <signal name="connection_closed">
<argument index="0" name="was_clean_close" type="bool">
</argument>
<description> <description>
Emitted when the connection to the server is closed. 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.
</description> </description>
</signal> </signal>
<signal name="connection_error"> <signal name="connection_error">
@ -64,6 +70,15 @@
Emitted when a WebSocket message is received. Note: This signal is NOT emitted when used as high level multiplayer peer. Emitted when a WebSocket message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
</description> </description>
</signal> </signal>
<signal name="server_close_request">
<argument index="0" name="code" type="int">
</argument>
<argument index="1" name="reason" type="String">
</argument>
<description>
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.
</description>
</signal>
</signals> </signals>
<constants> <constants>
</constants> </constants>

View File

@ -15,8 +15,14 @@
<method name="close"> <method name="close">
<return type="void"> <return type="void">
</return> </return>
<argument index="0" name="code" type="int" default="1000">
</argument>
<argument index="1" name="reason" type="String" default="&quot;&quot;">
</argument>
<description> <description>
Close this WebSocket connection, actively disconnecting the peer. Close this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC6455 section 7.4 for a list of valid status codes). [reason] is the human readable reason for closing the connection (can be any UTF8 string, must be less than 123 bytes).
Note: To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received.
Note: HTML5 export might not support all status codes. Please refer to browsers-specific documentation for more details.
</description> </description>
</method> </method>
<method name="get_connected_host" qualifiers="const"> <method name="get_connected_host" qualifiers="const">

View File

@ -18,8 +18,12 @@
</return> </return>
<argument index="0" name="id" type="int"> <argument index="0" name="id" type="int">
</argument> </argument>
<argument index="1" name="code" type="int" default="1000">
</argument>
<argument index="2" name="reason" type="String" default="&quot;&quot;">
</argument>
<description> <description>
Disconnects the given peer. Disconnects the peer identified by [code]id[/code] from the server. See [method WebSocketPeer.close] for more info.
</description> </description>
</method> </method>
<method name="get_peer_address" qualifiers="const"> <method name="get_peer_address" qualifiers="const">
@ -68,7 +72,7 @@
<description> <description>
Start listening on the given port. Start listening on the given port.
You can specify the desired subprotocols via the "protocols" array. If the list empty (default), "binary" will be used. You can specify the desired subprotocols via the "protocols" array. If the list empty (default), "binary" will be used.
You can use this server as a network peer for [MultiplayerAPI] by passing true as "gd_mp_api". Note: [signal data_received] will not be fired and clients other than Godot will not work in this case. 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.
</description> </description>
</method> </method>
<method name="stop"> <method name="stop">
@ -80,6 +84,17 @@
</method> </method>
</methods> </methods>
<signals> <signals>
<signal name="client_close_request">
<argument index="0" name="id" type="int">
</argument>
<argument index="1" name="code" type="int">
</argument>
<argument index="2" name="reason" type="String">
</argument>
<description>
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.
</description>
</signal>
<signal name="client_connected"> <signal name="client_connected">
<argument index="0" name="id" type="int"> <argument index="0" name="id" type="int">
</argument> </argument>
@ -92,8 +107,10 @@
<signal name="client_disconnected"> <signal name="client_disconnected">
<argument index="0" name="id" type="int"> <argument index="0" name="id" type="int">
</argument> </argument>
<argument index="1" name="was_clean_close" type="bool">
</argument>
<description> <description>
Emitted when a client disconnects. Emitted when a client disconnects. [code]was_clean_close[/code] will be [code]true[/code] if the connection was shutdown cleanly.
</description> </description>
</signal> </signal>
<signal name="data_received"> <signal name="data_received">