Click or drag to resize

WebSocketClientConnectToUrl Method

Connects to the given URL requesting one of the given protocols as sub-protocol. If the list empty (default), no sub-protocol will be requested.

If true is passed as gd_mp_api, the client will behave like a network peer for the MultiplayerAPI, connections to non-Godot servers will not work, and data_received will not be emitted.

If false is passed instead (default), you must call PacketPeer functions (put_packet, get_packet, etc.) on the WebSocketPeer returned via get_peer(1) and not on this object directly (e.g. get_peer(1).put_packet(data)).

You can optionally pass a list of custom_headers to be added to the handshake HTTP request.

Note: To avoid mixed content warnings or errors in HTML5, you may have to use a url that starts with wss:// (secure) instead of ws://. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's SSL certificate. Do not connect directly via the IP address for wss:// connections, as it won't match with the SSL certificate.

Note: Specifying custom_headers is not supported in HTML5 exports due to browsers restrictions.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public Error ConnectToUrl(
	string url,
	string[] protocols = null,
	bool gdMpApi = false,
	string[] customHeaders = null
)

Parameters

url
Type: SystemString

[Missing <param name="url"/> documentation for "M:Godot.WebSocketClient.ConnectToUrl(System.String,System.String[],System.Boolean,System.String[])"]

protocols (Optional)
Type: SystemString
If the parameter is null, then the default value is new string[] {}
gdMpApi (Optional)
Type: SystemBoolean

[Missing <param name="gdMpApi"/> documentation for "M:Godot.WebSocketClient.ConnectToUrl(System.String,System.String[],System.Boolean,System.String[])"]

customHeaders (Optional)
Type: SystemString
If the parameter is null, then the default value is new string[] {}

Return Value

Type: Error

[Missing <returns> documentation for "M:Godot.WebSocketClient.ConnectToUrl(System.String,System.String[],System.Boolean,System.String[])"]

See Also