web-udp
web-udp is a library used to establish UDP connections in Node/browser environments. The key goal of this project to provide a small, stable API that anyone can use to work with real-time data on the Web.
The library is currently implemented as an abstraction on top of unreliable RTCDataChannels. Since WebRTC is a dependency, a signaling server is included with the package to facilitate connections between clients. Client/server connections are available with the help of the wrtc package.
API
Signal<T>#Signal<T># Client#: Promise<Connection>Client#: Promise<string>Client#connections: Signal<Connection> Connection#: voidConnection#: voidConnection#closed: Signal<>Connection#errors: Signal< err: string >Connection#messages: Signal<*> // NodeServer#: ClientServer#connections: Signal<Connection>
Examples
Client/Server
// client.js ; { const client = ; const send messages = await client; ; messages;}
// server.js const server = ;const Server = ; const udp = server ; udpconnections; server;
P2P
// client.js { const left = ; const right = ; const route = await left; const connection = await right; leftconnections; connection;}
// server.js const server = ;const Server = ; ; server;