# `ZenWebsocket.Frame`
[🔗](https://github.com/ZenHive/zen_websocket/blob/v0.4.2/lib/zen_websocket/frame.ex#L1)

WebSocket frame encoding and decoding utilities.

## API Functions
| Function | Arity | Description | Param Kinds |
| --- | --- | --- | --- |
| `decode` | 1 | Decode an incoming WebSocket frame from Gun or direct format. | `frame: value` |
| `pong` | 1 | Create a WebSocket pong frame with optional payload. | `payload: value` |
| `ping` | 0 | Create a WebSocket ping frame. | - |
| `binary` | 1 | Encode binary data as a WebSocket frame. | `data: value` |
| `text` | 1 | Encode a text message as a WebSocket frame. | `message: value` |

# `frame`

```elixir
@type frame() :: {frame_type(), binary()}
```

# `frame_type`

```elixir
@type frame_type() :: :text | :binary | :ping | :pong | :close
```

# `binary`

```elixir
@spec binary(binary()) :: frame()
```

Encode binary message as WebSocket frame.

# `decode`

```elixir
@spec decode(tuple()) :: {:ok, frame()} | {:error, String.t()}
```

Decode incoming WebSocket frame.
Handles both Gun WebSocket format {:ws, type, data} and direct frame format {:type, data}.

# `ping`

```elixir
@spec ping() :: frame()
```

Create ping frame.

# `pong`

```elixir
@spec pong(binary()) :: frame()
```

Create pong frame with payload.

# `text`

```elixir
@spec text(String.t()) :: frame()
```

Encode text message as WebSocket frame.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
