Closes the connection. Ignored if no connection is currently established. If this is a server it tries to notify all clients before forcibly disconnecting them. If this is a client it simply closes the connection to the server.
Create client that connects to a server at address [code]ip[/code] using specified [code]port[/code]. The given IP needs to be in IPv4 or IPv6 address format, for example: [code]192.168.1.1[/code]. The [code]port[/code] is the port the server is listening on. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [code]OK[/code] if a client was created, [code]ERR_ALREADY_IN_USE[/code] if this NetworkedMultiplayerEnet instance already has an open connection (in which case you need to call [method close_connection] first) or [code]ERR_CANT_CREATE[/code] if the client could not be created.
Create client that connects to a server at [code]address[/code] using specified [code]port[/code]. The given address needs to be either a fully qualified domain nome (e.g. [code]www.example.com[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]192.168.1.1[/code]). The [code]port[/code] is the port the server is listening on. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [code]OK[/code] if a client was created, [code]ERR_ALREADY_IN_USE[/code] if this NetworkedMultiplayerEnet instance already has an open connection (in which case you need to call [method close_connection] first) or [code]ERR_CANT_CREATE[/code] if the client could not be created. If [code]client_port[/code] is specified, the client will also listen to the given port, this is useful in some NAT traveral technique.
</description>
</method>
<methodname="create_server">
...
...
@@ -50,6 +54,35 @@
Create server that listens to connections via [code]port[/code]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]*[/code], which listens on all available interfaces. [code]max_clients[/code] is the maximum number of clients that are allowed at once, any number up to 4096 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [code]OK[/code] if a server was created, [code]ERR_ALREADY_IN_USE[/code] if this NetworkedMultiplayerEnet instance already has an open connection (in which case you need to call [method close_connection] first) or [code]ERR_CANT_CREATE[/code] if the server could not be created.
This class implements a WebSocket client compatible with any RFC 6455 complaint WebSocket server.
This client can be optionally used as a network peer for the [MultiplayerAPI].
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]).
You will received appropriate signals when connecting, disconnecting, or when new data is available.
Connect to the given URL requesting one of the given [code]protocols[/code] as sub-protocol.
If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a network peer for the [MultiplayerAPI]. Note: connnections to non Godot servers will not work, and [signal data_received] will not be emitted when this option is true.
</description>
</method>
<methodname="disconnect_from_host">
<returntype="void">
</return>
<description>
Disconnect from the server if currently connected.
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.
</member>
</members>
<signals>
<signalname="connection_closed">
<description>
Emitted when the connection to the server is closed.
</description>
</signal>
<signalname="connection_error">
<description>
Emitted when the connection to the server fails.
</description>
</signal>
<signalname="connection_established">
<argumentindex="0"name="protocol"type="String">
</argument>
<description>
Emitted when a connection with the server is established, [code]protocol[/code] will contain the sub-protocol agreed with the server.
</description>
</signal>
<signalname="data_received">
<description>
Emitted when a WebSocket message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
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>
<demos>
</demos>
<methods>
<methodname="disconnect_peer">
<returntype="void">
</return>
<argumentindex="0"name="id"type="int">
</argument>
<description>
Disconnects the given peer.
</description>
</method>
<methodname="get_peer_address"qualifiers="const">
<returntype="String">
</return>
<argumentindex="0"name="id"type="int">
</argument>
<description>
Returns the IP address of the given peer.
</description>
</method>
<methodname="get_peer_port"qualifiers="const">
<returntype="int">
</return>
<argumentindex="0"name="id"type="int">
</argument>
<description>
Returns the remote port of the given peer.
</description>
</method>
<methodname="has_peer"qualifiers="const">
<returntype="bool">
</return>
<argumentindex="0"name="id"type="int">
</argument>
<description>
Returns [code]true[/code] if a peer with the given ID is connected.
</description>
</method>
<methodname="is_listening"qualifiers="const">
<returntype="bool">
</return>
<description>
Returns [code]true[/code] if the server is actively listening on a port.
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.
</description>
</method>
<methodname="stop">
<returntype="void">
</return>
<description>
Stop the server and clear its state.
</description>
</method>
</methods>
...
...
@@ -49,18 +86,21 @@
<argumentindex="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>
<signalname="client_disconnected">
<argumentindex="0"name="id"type="int">
</argument>
<description>
Emitted when a client disconnects.
</description>
</signal>
<signalname="data_received">
<argumentindex="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.