# pushwire-server
Generic, multiplexed push server for real-time applications. Built on [Axum](https://crates.io/crates/axum) with WebSocket and SSE transports.
Part of the [pushwire](https://crates.io/crates/pushwire) protocol family.
## Features
- **`PushServer<C>`** — generic over your `ChannelKind`, register per-channel handlers
- **WebSocket + SSE** — dual transport with `/rps` (WebSocket), `/rps/sse` (SSE), `/rps/ack` (HTTP POST)
- **Cursor-based replay** — clients resume after disconnect without message loss
- **Priority queuing** — high/normal/low lanes based on `ChannelKind::priority()`
- **Auth validation** — pluggable `AuthValidator` callback on handshake
- **Binary assets** — inline (base64) or pointer delivery with SHA-256 integrity
- **Transport manager** — Direct/P2P/Relay routing with automatic failover and backoff
- **Relay controller** — bandwidth-limited server-side relay with token-bucket rate limiting
- **WebRTC signaling** — optional peer-to-peer signaling relay (`rtc` feature)
## Quick start
```rust
use pushwire_server::PushServer;
use std::sync::Arc;
// Define MyChannel implementing ChannelKind (see pushwire-core)
let server: Arc<PushServer<MyChannel>> = Arc::new(PushServer::new());
for id in server.connected_client_ids() {
let _ = server.send(id, frame.clone());
}
});
let app = server.clone().router();
let listener = tokio::net::TcpListener::bind("0.0.0.0:9100").await.unwrap();
axum::serve(listener, app.into_make_service()).await.unwrap();
```
## Endpoints
| `/rps` | GET (WebSocket upgrade) | Primary push channel — auth handshake, bidirectional frames |
| `/rps/sse` | GET | Server-Sent Events stream — `?client_id=...&channels=chat,system` |
| `/rps/ack` | POST | HTTP acknowledgment — `{ client_id, channel, cursor }` |
## Feature flags
- **`rtc`** (default) — enables WebRTC signaling relay via `pushwire-core/rtc`
## License
Apache-2.0