---
id: "E:cAlgo.API.WebSocketClient.TextReceived"
kind: "event"
type: "T:cAlgo.API.WebSocketClient"
url: "https://help.ctrader.com/ctrader-algo/references/WebSocket/WebSocketClient/TextReceived/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# WebSocketClient.TextReceived

Member of [WebSocketClient](https://help.ctrader.com/ctrader-algo/references/WebSocket/WebSocketClient/index.md).

## TextReceived

Occurs when WebSocketClient receives text data.

Environments: Desktop supported · CLI supported · Cloud not supported.

- Cloud: 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.

C#:

```csharp
public event Action<WebSocketClientTextReceivedEventArgs> TextReceived;
```

Python:

```python
webSocketClient.TextReceived += handler  # handler(obj: WebSocketClientTextReceivedEventArgs)
```

### Returns

`Action<WebSocketClientTextReceivedEventArgs>` — 

### Examples

C#:

```csharp
private WebSocketClient _client;

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

private void OnTextReceived(WebSocketClientTextReceivedEventArgs args)
{
    Print("Received: {0}", args.Text);
}
```

Python:

```python
from System import Uri

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

def on_text_received(self, args):
    api.Print(f"Received: {args.Text}")
```

