Skip to content

Code Examples

Production-grade code recipes showing how to construct real-time systems, dashboard metrics, RPC workflows, multi-worker clustering, Python/Dart SDK pipelines, and OpenTelemetry observability.

1. Multi-Client Chat App

Demonstrates client subscription to a shared chat channel, broadcasting user frames, and handling messages:

2. Live Metrics Dashboard Stream

A lightweight telemetry script broadcasting performance metrics from server memory counters to all subscriber dashboards every second:

3. Request/Response (RPC) over Sockets

How to build a stateless Promise-based RPC request/response architecture on top of AfterLink's raw sequence numbers and ACK codes:

4. Automatic Client Reconnection

How to handle internet dropouts and socket pipe failures gracefully with AfterLink's native backoff reconnect parameters:

5. Node Clustering & Shared Pub/Sub (@ajaymyth/cluster)

Spawns multi-worker processes with Redis-backed shared pub/sub routing, worker crash detection, and SIGUSR2 zero-downtime rolling restarts:

6. Python SDK (Async Client & Server)

Build async Python servers and clients with full type hints, Pydantic model validation, priority queues, and Protocol v2 frame support:

7. Dart & Flutter SDK (Native TCP & Web Transports)

Cross-platform Dart client utilizing conditional compilation loaders for native TCP sockets (desktop/mobile) and WebSockets (web):

8. Prometheus Metrics & OpenTelemetry Tracing

Expose self-contained Prometheus metric scrape endpoints and propagate AsyncLocalStorage trace contexts with OpenTelemetry: