Skip to content

WebSocketClient.Dispose

method · WebSocketClient · cAlgo.API

DesktopCLICloud

Releases the unmanaged resources used by the WebSocketClient instance.

Environment behaviour

Cloud — works differently. Connects only to port 25345, and only on production cloud servers. Other ports fail to connect.

Definition

public void Dispose()
webSocketClient.Dispose() -> None

Examples

private WebSocketClient _client;

protected override void OnStart()
{
    _client = new WebSocketClient();
    _client.Connect(new Uri("wss://stream.example.com/quotes"));
}

protected override void OnStop()
{
    _client.Dispose();
    Print("WebSocket disposed, state: {0}", _client.State);
}
from System import Uri

def on_start(self):
    self.client = WebSocketClient()
    self.client.Connect(Uri("wss://stream.example.com/quotes"))

def on_stop(self):
    self.client.Dispose()
    api.Print(f"WebSocket disposed, state: {self.client.State}")