2018-05-08 12:40:08 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2019-04-01 10:33:56 +00:00
<class name= "WebSocketServer" inherits= "WebSocketMultiplayerPeer" category= "Core" version= "3.2" >
2018-05-08 12:40:08 +00:00
<brief_description >
A WebSocket server implementation
</brief_description>
<description >
This class implements a WebSocket server that can also support the high level multiplayer API.
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.
Note: This class will not work in HTML5 exports due to browser restrictions.
</description>
<tutorials >
</tutorials>
<methods >
<method name= "disconnect_peer" >
<return type= "void" >
</return>
<argument index= "0" name= "id" type= "int" >
</argument>
2018-09-23 23:49:09 +00:00
<argument index= "1" name= "code" type= "int" default= "1000" >
</argument>
<argument index= "2" name= "reason" type= "String" default= """" >
</argument>
2018-05-08 12:40:08 +00:00
<description >
2018-09-23 23:49:09 +00:00
Disconnects the peer identified by [code]id[/code] from the server. See [method WebSocketPeer.close] for more info.
2018-05-08 12:40:08 +00:00
</description>
</method>
<method name= "get_peer_address" qualifiers= "const" >
<return type= "String" >
</return>
<argument index= "0" name= "id" type= "int" >
</argument>
<description >
Returns the IP address of the given peer.
</description>
</method>
<method name= "get_peer_port" qualifiers= "const" >
<return type= "int" >
</return>
<argument index= "0" name= "id" type= "int" >
</argument>
<description >
Returns the remote port of the given peer.
</description>
</method>
<method name= "has_peer" qualifiers= "const" >
<return type= "bool" >
</return>
<argument index= "0" name= "id" type= "int" >
</argument>
<description >
Returns [code]true[/code] if a peer with the given ID is connected.
</description>
</method>
<method name= "is_listening" qualifiers= "const" >
<return type= "bool" >
</return>
<description >
Returns [code]true[/code] if the server is actively listening on a port.
</description>
</method>
<method name= "listen" >
<return type= "int" enum= "Error" >
</return>
<argument index= "0" name= "port" type= "int" >
</argument>
<argument index= "1" name= "protocols" type= "PoolStringArray" default= "PoolStringArray( )" >
</argument>
<argument index= "2" name= "gd_mp_api" type= "bool" default= "false" >
</argument>
<description >
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.
2019-01-27 13:59:25 +00:00
If [code]true[/code] is passed as [code]gd_mp_api[/code], the server will behave like a network peer for the [MultiplayerAPI], connections from non Godot clients will not work, and [signal data_received] will not be emitted.
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(ID)[/code] to communicate with the peer with given [code]ID[/code] (e.g. [code]get_peer(ID).get_available_packet_count[/code]).
2018-05-08 12:40:08 +00:00
</description>
</method>
<method name= "stop" >
<return type= "void" >
</return>
<description >
Stop the server and clear its state.
</description>
</method>
</methods>
<signals >
2018-09-23 23:49:09 +00:00
<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>
2018-05-08 12:40:08 +00:00
<signal name= "client_connected" >
<argument index= "0" name= "id" type= "int" >
</argument>
<argument index= "1" name= "protocol" type= "String" >
</argument>
<description >
Emitted when a new client connects. "protocol" will be the sub-protocol agreed with the client.
</description>
</signal>
<signal name= "client_disconnected" >
<argument index= "0" name= "id" type= "int" >
</argument>
2018-09-23 23:49:09 +00:00
<argument index= "1" name= "was_clean_close" type= "bool" >
</argument>
2018-05-08 12:40:08 +00:00
<description >
2018-09-23 23:49:09 +00:00
Emitted when a client disconnects. [code]was_clean_close[/code] will be [code]true[/code] if the connection was shutdown cleanly.
2018-05-08 12:40:08 +00:00
</description>
</signal>
<signal name= "data_received" >
<argument index= "0" name= "id" type= "int" >
</argument>
<description >
Emitted when a new message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
</description>
</signal>
</signals>
<constants >
</constants>
</class>