What ngnet is
A generic network layer for Ace of Spades style games and servers, in C.
- ENet for native UDP players (classic ENet 1.3 or enet6).
- WebRTC DataChannels for browser players (libdatachannel, one UDP port).
- The client of a master server, which is both the server list and the WebRTC signalling: signed announce, long poll for offers, join codes,
/serverlist.json.
It carries bytes. It has no game types and no protocol knowledge: the uint32 *connect data* is opaque (it is ENet’s connect data, or the n of the DataChannel’s connect <n> line), the list of masters is passed in by the program, and nothing is allow-listed. It is written so that third-party servers such as LSD and SpadesX can use it with a handful of changed lines.
Licence: GPL-3.0-or-later.
Three ways to use it
| Level | For | What you write |
|---|---|---|
ENet shim (ngnet/enet.h) | a server that already speaks ENet | nothing in the code: compile with -include ngnet/enet.h |
Lua binding (ngnet/lua.h) | a server with an embedded Lua config | #include <ngnet/lua.h> and one ngnet_lua_open(L) |
Native API (ngnet/ngnet.h) | a new game or a server that wants full control | ngnet_server_start(port, &events), ngnet_service() every tick |