Drivers route signaling messages between peers over any transport
(MQTT, NATS, SSE, etc.). Implement subscribe, unsubscribe, and
publish to handle message routing by namespace. The active
property reflects the connection state.
Peerix minimizes signaling overhead by migrating connections to a
dedicated data channel after handshake, using binary messages,
debouncing ICE candidates, compressing payloads, and supporting
built-in namespace hashing and end-to-end encryption (E2EE).
%%{init:{"theme":"dark"}}%%
sequenceDiagram
Peer A -->> Peer B: broadcast announce
Peer B ->> Peer A: invoke
Peer A ->> Peer B: SDP offer
Peer B ->> Peer A: SDP answer
Peer B <<->> Peer A: ICE candidates
%%{init:{"theme":"default"}}%%
sequenceDiagram
Peer A -->> Peer B: broadcast announce
Peer B ->> Peer A: invoke
Peer A ->> Peer B: SDP offer
Peer B ->> Peer A: SDP answer
Peer B <<->> Peer A: ICE candidates
sequenceDiagram
Peer A -->> Peer B: broadcast announce
Peer B ->> Peer A: invoke
Peer A ->> Peer B: SDP offer
Peer B ->> Peer A: SDP answer
Peer B <<->> Peer A: ICE candidates
This flow runs automatically. Connecting two peers takes about
4 messages per peer, roughly 1 KB with compression and
encryption enabled.
Signaling Type
Sent Size
Overhead
Raw Signaling
1468 bytes
0%
Encrypted Signaling
1551 bytes
+5%
Compressed Signaling
806 bytes
-45%
Compressed & Encrypted
891 bytes
-40%
Sometimes the built-in signaling drivers may not fit your specific use case or
requirements. In such cases you can implement your own custom driver by extending
this class and overriding subscribe, unsubscribe, and publish:
import { Driver } from"peerix";
classMyDriverextendsDriver { asyncsubscribe(namespace: string, handler: (data: number[]) =>void) { // implement subscription logic for the given namespace and handler } asyncunsubscribe(namespace: string, handler: (data: number[]) =>void) { // implement unsubscription logic for the given namespace and handler } asyncpublish(namespace: string, data: number[]) { // implement publish logic for the given namespace and message } }
Drivers route signaling messages between peers over any transport (MQTT, NATS, SSE, etc.). Implement
subscribe,unsubscribe, andpublishto handle message routing by namespace. Theactiveproperty reflects the connection state.Peerix minimizes signaling overhead by migrating connections to a dedicated data channel after handshake, using binary messages, debouncing ICE candidates, compressing payloads, and supporting built-in namespace hashing and end-to-end encryption (E2EE).
This flow runs automatically. Connecting two peers takes about 4 messages per peer, roughly 1 KB with compression and encryption enabled.
Sometimes the built-in signaling drivers may not fit your specific use case or requirements. In such cases you can implement your own custom driver by extending this class and overriding
subscribe,unsubscribe, andpublish:Then use it: