WebSocketclass

A WebSocket client for connecting to external services.

objectWebSocket
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.WebSocket

Note

Events handlers will be called on the synchronization context that Connect was called on.

Constructors1

Showing 1 constructors

public WebSocket(int maxMessageSize = 65536)PUBLICCONSTRUCTOR

Initialized a new WebSocket client.

ParameterTypeDescription
maxMessageSize = 65536intThe maximum message size to allow from the server, in bytes. Default 64 KiB.

Methods8

Showing 8 methods

public void AddSubProtocol(string protocol)PUBLIC

Add a sub-protocol to be negotiated during the WebSocket connection handshake.

ParameterTypeDescription
protocolstring
Returns:void

public virtual sealed void Dispose()PUBLICVIRTUAL

Cleans up resources used by the WebSocket client. This will also immediately close the connection if it is currently open.

Returns:void

Properties3

Showing 3 properties

public bool Sandbox.WebSocket.EnableCompression { get; set; }PUBLICGETSET

Enable or disable compression for the websocket. If the server supports it, compression will be enabled for all messages. Note: compression is disabled by default, and can be dangerous if you are sending secrets across the network.

Returns:bool

public bool Sandbox.WebSocket.IsConnected { get; set; }PUBLICGETSET

Returns true as long as a WebSocket connection is established.

Returns:bool

public string Sandbox.WebSocket.SubProtocol { get; set; }PUBLICGETSET

Get the sub-protocol that was negotiated during the opening handshake.

Returns:string

On this page