chumicro-websockets¶
Non-blocking WebSocket (RFC 6455) client and server for CircuitPython, MicroPython, and CPython.
An LED keeps blinking through the handshake, frame I/O, and the close handshake — both sides take small turns on every runner tick instead of holding the loop.
Quick example¶
from chumicro_websockets import WebSocketClient, WebSocketState
from chumicro_sockets.sockets_factory import connector_factory
from chumicro_timing import ticks_ms
from chumicro_wifi import wifi
client = WebSocketClient(
transport_factory=connector_factory(radio=wifi.adapter.radio),
)
client.on_text = lambda text: print(text)
client.connect("ws://api.example.com/stream")
while client.state != WebSocketState.CLOSED:
now = ticks_ms()
if client.check(now):
client.handle(now)
Documentation¶
- User Guide — getting started and usage patterns
- API Reference — full API documentation
- Testing Helpers — fakes for downstream test suites