> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.agentchat.realtime.experimental.websockets.WebSocketProtocol

<h2 id="autogen.agentchat.realtime.experimental.websockets.WebSocketProtocol" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">WebSocketProtocol</span>
</h2>

```python theme={null}
WebSocketProtocol(*args, **kwargs)
```

WebSocket protocol for sending and receiving JSON data modelled after FastAPI's WebSocket.

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `*args`    |             |
| `**kwargs` |             |

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### iter\_text

```python theme={null}
iter_text(self) -> AsyncIterator[str]
```

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### receive\_json

```python theme={null}
receive_json(self, mode: str = 'text') -> Any
```

<b>Parameters:</b>

| Name   | Description                                  |
| ------ | -------------------------------------------- |
| `mode` | **Type:** str<br /><br />**Default:** 'text' |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### receive\_text

```python theme={null}
receive_text(self) -> str
```

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### send\_json

```python theme={null}
send_json(
    self,
    data: Any,
    mode: str = 'text'
) -> None
```

<b>Parameters:</b>

| Name   | Description                                  |
| ------ | -------------------------------------------- |
| `data` | **Type:** Any                                |
| `mode` | **Type:** str<br /><br />**Default:** 'text' |

<br />
