WebSocketMultiplayerPeer
Base class for WebSocket server and client.
Base class for WebSocket server and client.
Base class for WebSocket server and client, allowing them to be used as multiplayer peer for the MultiplayerApi.
Note: When exporting to Android, make sure to enable the INTERNET permission in the Android export preset before exporting the project or using remote deploy. Otherwise, network communication of any kind will be blocked by Android.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
WebSocketMultiplayerPeerConstructor
public WebSocketMultiplayerPeer();Properties6
HandshakeHeadersProperty
public string[] HandshakeHeaders { get; set; }The extra headers to use during handshake. See WebSocketPeer.HandshakeHeaders for more details.
HandshakeTimeoutProperty
public float HandshakeTimeout { get; set; }The maximum time each peer can stay in a connecting state before being dropped.
InboundBufferSizeProperty
public int InboundBufferSize { get; set; }The inbound buffer size for connected peers. See WebSocketPeer.InboundBufferSize for more details.
MaxQueuedPacketsProperty
public int MaxQueuedPackets { get; set; }The maximum number of queued packets for connected peers. See WebSocketPeer.MaxQueuedPackets for more details.
OutboundBufferSizeProperty
public int OutboundBufferSize { get; set; }The outbound buffer size for connected peers. See WebSocketPeer.OutboundBufferSize for more details.
SupportedProtocolsProperty
public string[] SupportedProtocols { get; set; }The supported WebSocket sub-protocols. See WebSocketPeer.SupportedProtocols for more details.
Methods19
CreateClientError
public Error CreateClient(string url, TlsOptions tlsClientOptions = null);Starts a new multiplayer client connecting to the given url. TLS certificates will be verified against the hostname when connecting using the wss:// protocol. You can pass the optional tls_client_options parameter to customize the trusted certification authorities, or disable the common name verification. See TlsOptions.Client and TlsOptions.ClientUnsafe.
Note: It is recommended to specify the scheme part of the URL, i.e. the url should start with either ws:// or wss://.
| Name | Type | Default |
|---|---|---|
url | string | — |
tlsClientOptions | TlsOptions | null |
ErrorCreateServerError
public Error CreateServer(int port, string bindAddress = "*", TlsOptions tlsServerOptions = null);Starts a new multiplayer server listening on the given port. You can optionally specify a bind_address, and provide valid tls_server_options to use TLS. See TlsOptions.Server.
| Name | Type | Default |
|---|---|---|
port | int | — |
bindAddress | string | "*" |
tlsServerOptions | TlsOptions | null |
ErrorGetHandshakeHeadersstring[]
public string[] GetHandshakeHeaders();string[]GetHandshakeTimeoutfloat
public float GetHandshakeTimeout();floatGetInboundBufferSizeint
public int GetInboundBufferSize();intGetMaxQueuedPacketsint
public int GetMaxQueuedPackets();intGetOutboundBufferSizeint
public int GetOutboundBufferSize();intGetPeerWebSocketPeer
public WebSocketPeer GetPeer(int peerId);Returns the WebSocketPeer associated to the given peer_id.
| Name | Type | Default |
|---|---|---|
peerId | int | — |
WebSocketPeerGetPeerAddressstring
public string GetPeerAddress(int id);Returns the IP address of the given peer.
| Name | Type | Default |
|---|---|---|
id | int | — |
stringGetPeerPortint
public int GetPeerPort(int id);Returns the remote port of the given peer.
| Name | Type | Default |
|---|---|---|
id | int | — |
intGetSupportedProtocolsstring[]
public string[] GetSupportedProtocols();string[]SetHandshakeHeaders2 overloads
public void SetHandshakeHeaders(ReadOnlySpan<string> protocols);| Name | Type | Default |
|---|---|---|
protocols | ReadOnlySpan<string> | — |
public void SetHandshakeHeaders(string[] protocols);| Name | Type | Default |
|---|---|---|
protocols | string[] | — |
SetHandshakeTimeoutvoid
public void SetHandshakeTimeout(float timeout);| Name | Type | Default |
|---|---|---|
timeout | float | — |
SetInboundBufferSizevoid
public void SetInboundBufferSize(int bufferSize);| Name | Type | Default |
|---|---|---|
bufferSize | int | — |
SetMaxQueuedPacketsvoid
public void SetMaxQueuedPackets(int maxQueuedPackets);| Name | Type | Default |
|---|---|---|
maxQueuedPackets | int | — |
SetOutboundBufferSizevoid
public void SetOutboundBufferSize(int bufferSize);| Name | Type | Default |
|---|---|---|
bufferSize | int | — |
SetSupportedProtocols2 overloads
public void SetSupportedProtocols(ReadOnlySpan<string> protocols);| Name | Type | Default |
|---|---|---|
protocols | ReadOnlySpan<string> | — |
public void SetSupportedProtocols(string[] protocols);| Name | Type | Default |
|---|---|---|
protocols | string[] | — |