Skip to content

WebSocketClient.Send

method · WebSocketClient · cAlgo.API

DesktopCLICloud

Sends passed text.

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
Send(string text) Sends passed text.
Send(byte[] data) Sends passed binary data.

Send(string text)

Sends passed text.

public void Send(string text)
webSocketClient.Send(text: str) -> None

Parameters

Name C# type Python type Description
text string str Text to send.

Examples

var client = new WebSocketClient();
client.Connected += args => args.Client.Send("subscribe " + SymbolName);
client.Connect(new Uri("wss://stream.example.com/quotes"));
from System import Uri

client = WebSocketClient()
client.Connected += lambda args: args.Client.Send(f"subscribe {api.SymbolName}")
client.Connect(Uri("wss://stream.example.com/quotes"))

Send(byte[] data)

Sends passed binary data.

public void Send(byte[] data)
webSocketClient.Send(data: list[int]) -> None

Parameters

Name C# type Python type Description
data byte[] list[int] Data to send.

Examples

var client = new WebSocketClient();
client.Connected += args => args.Client.Send(Encoding.UTF8.GetBytes("ping"));
client.Connect(new Uri("wss://stream.example.com/quotes"));
from System import Uri
from System.Text import Encoding

client = WebSocketClient()
client.Connected += lambda args: args.Client.Send(Encoding.UTF8.GetBytes("ping"))
client.Connect(Uri("wss://stream.example.com/quotes"))