# Sandbox.WebSocket

A WebSocket client for connecting to external services.

## Remarks

Events handlers will be called on the synchronization context that Connect was called on.

- Kind: class
- Namespace: `Sandbox`
- Assembly: `Sandbox.Engine`
- Modifiers: sealed

## Constructors

- [`WebSocket`](/api/Sandbox.WebSocket/.ctor): Initialized a new WebSocket client.

## Properties

- [`EnableCompression`](/api/Sandbox.WebSocket/EnableCompression): 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.
- [`IsConnected`](/api/Sandbox.WebSocket/IsConnected): Returns true as long as a WebSocket connection is established.
- [`SubProtocol`](/api/Sandbox.WebSocket/SubProtocol): Get the sub-protocol that was negotiated during the opening handshake.

## Methods

- [`AddSubProtocol`](/api/Sandbox.WebSocket/AddSubProtocol): Add a sub-protocol to be negotiated during the WebSocket connection handshake.
- [`Connect`](/api/Sandbox.WebSocket/Connect): Establishes a connection to an external WebSocket service.
- [`Dispose`](/api/Sandbox.WebSocket/Dispose): Cleans up resources used by the WebSocket client. This will also immediately close the connection if it is currently open.
- [`Send`](/api/Sandbox.WebSocket/Send): Sends a text message to the WebSocket server.
