Skip to content

WebSocketClient constructor

constructor · WebSocketClient · cAlgo.API

DesktopCLICloud

Creates a WebSocketClient with default options.

Environment behaviour

Cloud — not supported. Connect, Send and Close do nothing: "WebSocket is not supported in cloud environment." is written to the log, State stays None and no events are raised.

Overloads

Signature Description
WebSocketClient() Creates a WebSocketClient with default options.
WebSocketClient(WebSocketClientOptions options) Creates a WebSocketClient with passed options.

WebSocketClient()

Creates a WebSocketClient with default options.

public WebSocketClient()
WebSocketClient()

Examples

var client = new WebSocketClient();
client.TextReceived += args => Print("Received: {0}", args.Text);
client.Connect(new Uri("wss://stream.example.com/quotes"));
from System import Uri

client = WebSocketClient()
client.TextReceived += lambda args: api.Print(f"Received: {args.Text}")
client.Connect(Uri("wss://stream.example.com/quotes"))

WebSocketClient(WebSocketClientOptions options)

Creates a WebSocketClient with passed options.

public WebSocketClient(WebSocketClientOptions options)
WebSocketClient(options: WebSocketClientOptions)

Parameters

Name C# type Python type Description
options WebSocketClientOptions WebSocketClientOptions

Examples

var options = new WebSocketClientOptions { KeepAliveInterval = TimeSpan.FromSeconds(10) };
var client = new WebSocketClient(options);
client.Connect(new Uri("wss://stream.example.com/quotes"));
from System import Uri, TimeSpan

options = WebSocketClientOptions()
options.KeepAliveInterval = TimeSpan.FromSeconds(10)
client = WebSocketClient(options)
client.Connect(Uri("wss://stream.example.com/quotes"))