2018-05-08 14:40:08 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-03-16 23:01:02 +01:00
<class name= "WebSocketServer" inherits= "WebSocketMultiplayerPeer" version= "3.5" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../../../doc/class.xsd" >
2018-05-08 14:40:08 +02:00
<brief_description >
2019-06-22 01:04:47 +02:00
A WebSocket server implementation.
2018-05-08 14:40:08 +02:00
</brief_description>
<description >
2019-06-22 01:04:47 +02:00
This class implements a WebSocket server that can also support the high-level multiplayer API.
2018-05-08 14:40:08 +02:00
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.
2020-01-14 13:54:31 +01:00
[b]Note:[/b] Not available in HTML5 exports.
2018-05-08 14:40:08 +02:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "disconnect_peer" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
<argument index= "0" name= "id" type= "int" />
<argument index= "1" name= "code" type= "int" default= "1000" />
<argument index= "2" name= "reason" type= "String" default= """" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Disconnects the peer identified by [code]id[/code] from the server. See [method WebSocketPeer.close] for more information.
2018-05-08 14:40:08 +02:00
</description>
</method>
<method name= "get_peer_address" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "String" />
<argument index= "0" name= "id" type= "int" />
2018-05-08 14:40:08 +02:00
<description >
Returns the IP address of the given peer.
</description>
</method>
<method name= "get_peer_port" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
<argument index= "0" name= "id" type= "int" />
2018-05-08 14:40:08 +02:00
<description >
Returns the remote port of the given peer.
</description>
</method>
<method name= "has_peer" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
<argument index= "0" name= "id" type= "int" />
2018-05-08 14:40:08 +02:00
<description >
Returns [code]true[/code] if a peer with the given ID is connected.
</description>
</method>
<method name= "is_listening" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2018-05-08 14:40:08 +02:00
<description >
Returns [code]true[/code] if the server is actively listening on a port.
</description>
</method>
<method name= "listen" >
2021-07-30 15:28:05 +02:00
<return type= "int" enum= "Error" />
<argument index= "0" name= "port" type= "int" />
<argument index= "1" name= "protocols" type= "PoolStringArray" default= "PoolStringArray( )" />
<argument index= "2" name= "gd_mp_api" type= "bool" default= "false" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Starts listening on the given port.
2019-06-24 15:46:24 +02:00
You can specify the desired subprotocols via the "protocols" array. If the list empty (default), no sub-protocol will be requested.
2019-06-22 01:04:47 +02: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.
2019-06-27 12:34:26 +02:00
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 14:40:08 +02:00
</description>
</method>
2022-04-12 16:50:53 +02:00
<method name= "set_extra_headers" >
<return type= "void" />
<argument index= "0" name= "headers" type= "PoolStringArray" default= "PoolStringArray( )" />
<description >
Sets additional headers to be sent to clients during the HTTP handshake.
</description>
</method>
2018-05-08 14:40:08 +02:00
<method name= "stop" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Stops the server and clear its state.
2018-05-08 14:40:08 +02:00
</description>
</method>
</methods>
2019-10-08 20:56:10 +02:00
<members >
2020-01-16 10:59:01 +01:00
<member name= "bind_ip" type= "String" setter= "set_bind_ip" getter= "get_bind_ip" default= ""*"" >
2020-01-02 15:02:29 +01:00
When not set to [code]*[/code] will restrict incoming connections to the specified IP address. Setting [code]bind_ip[/code] to [code]127.0.0.1[/code] will cause the server to listen only to the local host.
</member>
2019-10-08 20:56:10 +02:00
<member name= "ca_chain" type= "X509Certificate" setter= "set_ca_chain" getter= "get_ca_chain" >
When using SSL (see [member private_key] and [member ssl_certificate]), you can set this to a valid [X509Certificate] to be provided as additional CA chain information during the SSL handshake.
</member>
2021-06-28 14:31:15 +02:00
<member name= "handshake_timeout" type= "float" setter= "set_handshake_timeout" getter= "get_handshake_timeout" default= "3.0" >
The time in seconds before a pending client (i.e. a client that has not yet finished the HTTP handshake) is considered stale and forcefully disconnected.
</member>
2019-10-08 20:56:10 +02:00
<member name= "private_key" type= "CryptoKey" setter= "set_private_key" getter= "get_private_key" >
2019-10-11 08:45:03 +02:00
When set to a valid [CryptoKey] (along with [member ssl_certificate]) will cause the server to require SSL instead of regular TCP (i.e. the [code]wss://[/code] protocol).
2019-10-08 20:56:10 +02:00
</member>
<member name= "ssl_certificate" type= "X509Certificate" setter= "set_ssl_certificate" getter= "get_ssl_certificate" >
2019-10-11 08:45:03 +02:00
When set to a valid [X509Certificate] (along with [member private_key]) will cause the server to require SSL instead of regular TCP (i.e. the [code]wss://[/code] protocol).
2019-10-08 20:56:10 +02:00
</member>
</members>
2018-05-08 14:40:08 +02:00
<signals >
2018-09-24 01:49:09 +02:00
<signal name= "client_close_request" >
2021-07-30 15:28:05 +02:00
<argument index= "0" name= "id" type= "int" />
<argument index= "1" name= "code" type= "int" />
<argument index= "2" name= "reason" type= "String" />
2018-09-24 01:49:09 +02:00
<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 14:40:08 +02:00
<signal name= "client_connected" >
2021-07-30 15:28:05 +02:00
<argument index= "0" name= "id" type= "int" />
<argument index= "1" name= "protocol" type= "String" />
2018-05-08 14:40:08 +02:00
<description >
Emitted when a new client connects. "protocol" will be the sub-protocol agreed with the client.
</description>
</signal>
<signal name= "client_disconnected" >
2021-07-30 15:28:05 +02:00
<argument index= "0" name= "id" type= "int" />
<argument index= "1" name= "was_clean_close" type= "bool" />
2018-05-08 14:40:08 +02:00
<description >
2018-09-24 01:49:09 +02: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 14:40:08 +02:00
</description>
</signal>
<signal name= "data_received" >
2021-07-30 15:28:05 +02:00
<argument index= "0" name= "id" type= "int" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Emitted when a new message is received.
[b]Note:[/b] This signal is [i]not[/i] emitted when used as high-level multiplayer peer.
2018-05-08 14:40:08 +02:00
</description>
</signal>
</signals>
<constants >
</constants>
</class>