AtlatestRepositorysigil-websocket
1# sigil-websocket
2
3A [Sigil](https://codeberg.org/sigil/sigil) library for WebSocket client connections (RFC 6455). Supports both `ws://` and `wss://` (TLS) with cooperative non-blocking I/O.
4
5## Features
6
7- **TLS support** -- connect to `ws://` and `wss://` endpoints
8- **Frame encoding/decoding** -- text, binary, ping, pong, close
9- **Client masking** -- automatic frame masking per RFC 6455
10- **Fragmentation** -- transparent message reconstruction from continuation frames
11- **Cooperative I/O** -- non-blocking receive that yields to the scheduler
13## Usage
15Add `sigil-websocket` as a dependency in your `package.sgl`:
17```scheme
18(from-git url: "codeberg:sigil/sigil-websocket" package: "sigil-websocket")
19```
21Then connect and exchange messages:
23```scheme
24(import (sigil websocket))
26(define ws (ws-connect "wss://echo.websocket.org"))
28(ws-send ws "Hello, WebSocket!")
30(let loop ()
31 (let ((msg (ws-receive ws)))
32 (when (string? msg)
33 (display msg)
34 (loop))))
36(ws-close ws)
37```
39## Modules
41| Module | Description |
42|--------|-------------|
43| `(sigil websocket)` | Top-level re-exports |
44| `(sigil websocket frame)` | Frame encoding, decoding, masking |
45| `(sigil websocket connection)` | Handshake, send, receive, close |
47## Dependencies
49- sigil-stdlib
50- sigil-socket
51- sigil-crypto
53## Building
55```bash
56sigil deps install
57sigil build
58sigil test
59```
61## License
63BSD-3-Clause