#webrtc #udp #server #gamedev #networking

naia-server-socket

An abstraction to provide a common API over either a UDP socket or a service that can establish WebRTC connections

15 unstable releases (4 breaking)

0.5.0 May 2, 2021
0.4.2 Nov 29, 2020
0.3.0 Jul 13, 2020

#547 in Network programming

Download history 56/week @ 2021-06-02 36/week @ 2021-06-09 43/week @ 2021-06-16 51/week @ 2021-06-23 29/week @ 2021-06-30 48/week @ 2021-07-07 93/week @ 2021-07-14 31/week @ 2021-07-21 103/week @ 2021-07-28 70/week @ 2021-08-04 46/week @ 2021-08-11 27/week @ 2021-08-18 41/week @ 2021-08-25 36/week @ 2021-09-01 55/week @ 2021-09-08 54/week @ 2021-09-15

295 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

53KB
1.5K SLoC

Build Status Latest Version API Documentation Discord chat MIT/Apache

naia-socket

A cross-platform (including Wasm!) Socket API that wraps unreliable & unordered communication, using WebRTC & UDP.

Utilizes Kyren's wonderful webrtc-unreliable

naia-client-socket is usable with both wasm-bindgen and miniquad (build for these with the feature wbindgen & mquad, respectively)

Demos

Server:

To run a UDP server on Linux: (that will be able to communicate with Linux clients)

1. `cd demo/server`
2. `cargo run --features "use-udp"`

To run a WebRTC server on Linux: (that will be able to communicate with Web clients)

1. `cd demo/server`
2. `cargo run --features "use-webrtc"`

Client:

To run a UDP client on Linux: (that will be able to communicate with a UDP server)

1. `cd demo/client/wasm_bindgen`
2. `cargo run`

To run a WebRTC client on Web using wasm-bindgen: (that will be able to communicate with a WebRTC server)

1. Enter in your IP Address at the appropriate spot in demo/client/wasm-bindgen/src/app.rs
2. `cd demo/client/wasm_bindgen`
3. `npm install`              //should only need to do this once to install dependencies
4. `npm run start`            //this will open a web browser, and hot reload

To run a WebRTC client on Web using miniquad: (that will be able to communicate with a WebRTC server)

1. Enter in your IP Address at the appropriate spot in demo/client/miniquad/src/app.rs
2. `cargo install watchexec`   //should only need to do this once to install watchexec, which will auto-reload for you
3. `sh demo/client/miniquad/deploy.sh`               //this will open a web browser, and hot reload

To simply build these demos instead of running them, substitute the above commands like so:

`cargo build` for `cargo run`, and

`npm run build` for `npm run start`

Dependencies

~2–3.5MB
~63K SLoC