Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nathhB authored Jan 6, 2024
1 parent 0b9c7b9 commit ad2c3c3
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@

![logo](logo/logo.png "Logo")

[![Build Status](https://app.travis-ci.com/nathhB/nbnet.svg?branch=master)](https://app.travis-ci.com/nathhB/nbnet)
[![Docs site](https://img.shields.io/badge/docs-GitHub_Pages-blue)](https://nathhb.github.io/nbnet)
![nbnet](https://github.com/nathhB/nbnet/actions/workflows/nbnet.yml/badge.svg)
[![CodeFactor](https://www.codefactor.io/repository/github/nathhb/nbnet/badge/master)](https://www.codefactor.io/repository/github/nathhb/nbnet/overview/master)
[![Docs site](https://img.shields.io/badge/docs-GitHub_Pages-blue)](https://nathhb.github.io/nbnet)

[![](https://dcbadge.vercel.app/api/server/P9N7fy677D)](https://discord.gg/P9N7fy677D)

nbnet is a single header C (C99) library to implement client-server network code for games. It is more precisely designed for fast-paced action games.
nbnet is a single header C (C99) library designed to implement client-server architecture, more precisely for online video games. The library is based on this [great series of articles](https://gafferongames.com/) by Glenn Fiedler.

nbnet is based on this [great series of articles](https://gafferongames.com/) by Glenn Fiedler.
nbnet can target different protocols such as UDP or WebRTC through "drivers" (see below for more information).

nbnet aims to be as easy to use as possible. nbnet's API is *friendly* and goes *straight to the point*; it relies on event polling which makes it easy to integrate into a game loop.
The API is meant to be as straightforward as possible and relies on event polling, making it easy to integrate into a game loop.

**Disclaimer**: nbnet is in the early stages of its development and is, first and foremost, a learning project of mine as I explore online game development. If you are looking for a professional production-ready library, this is not the one.
**Disclaimer**: nbnet is in the early stages of its development and is, first and foremost, a learning project of mine as I explore online game development. If you are looking for a battle-tested, production-ready library, this is probably not the one.

You can see nbnet in action [in this video](https://www.youtube.com/watch?v=BJl_XN3QJhQ&ab_channel=NathanBIAGINI).

If you want to discuss the library, you can join the [nbnet's discord server](https://discord.gg/esR8FSyPnF).
If you want to discuss the library or need help, join the [nbnet's discord server](https://discord.gg/esR8FSyPnF).

## Features

- Connection management
- Sending/Receiving both reliable ordered and unreliable ordered messages
- Sending/Receiving messages larger than the MTU (using nbnet's message fragmentation)
- Bit-level serialization (for bandwidth optimization): integers (signed and unsigned), floats, booleans, and byte arrays
- Network conditions simulation: ping, jitter, packet loss, packet duplication, and out of order packets)
- Network conditions simulation: ping, jitter, packet loss, packet duplication, and out-of-order packets)
- Network statistics: ping, bandwidth (upload and download) and packet loss
- Web (WebRTC) support (both natively and through WASM using [emscripten](https://emscripten.org/docs/introducing_emscripten/about_emscripten.html))
- Encrypted and authenticated packets

## Thanks

nbnet encryption and packet authentication would not have been possible without those three open-source libraries:
nbnet encryption and packet authentication use the following open-source libraries:

- [tiny-ECDH](https://github.com/kokke/tiny-ECDH-c)
- [tiny-AES](https://github.com/kokke/tiny-AES-c)
- [poly1305-donna](https://github.com/floodyberry/poly1305-donna)

and the native WebRTC driver would not exist without these ones:
the native WebRTC driver relies on:

- [facil.io](https://github.com/boazsegev/facil.io)
- [libdatachannel](https://github.com/paullouisageneau/libdatachannel)
Expand Down Expand Up @@ -74,40 +74,32 @@ A little online tank game prototype.
## Bindings

A list of user-contributed bindings (they are not officially supported, so they may be outdated):
- [nbnet.nim](https://github.com/Tail-Wag-Games/arkana/blob/master/thirdparty/nbnet.nim) by [@zacharycarter](https://github.com/zacharycarter)

- [nbnet-sunder](https://github.com/ashn-dot-dev/nbnet-sunder) by [@ashn](https://github.com/ashn-dot-dev) ([Sunder](https://github.com/ashn-dot-dev/sunder) is a C-like systems programming language and compiler for x86-64 Linux, ARM64 Linux, and WebAssembly)

## Drivers

nbnet does not directly implement any low level "transport" code and rely on *drivers*.
nbnet does not directly implement any low-level "transport" code and relies on *drivers*.

A driver is a set of function definitions that live outside the nbnet header and provide a transport layer implementation for nbnet used to send and receive packets.

nbnet comes with two ready to use drivers:

- UDP : work with a single UDP socket, designed for desktop games
- WebRTC : work with a single unreliable/unordered data channel, designed for web browser games

## Portability

nbnet is developed with portability in mind. I tested (and will continue to do so) the library on the following platforms:
nbnet comes with three ready-to-use drivers:

- Windows
- OSX
- Linux
- Web (Chrome/Firefox/Microsoft Edge/Brave)
- UDP: works with a single UDP socket, designed for desktop games
- WebRTC (WASM): works with a single unreliable/unordered data channel, implemented in JS using emscripten API
- WebRTC (Native): works the same way as the WASM WebRTC driver but can be natively compiled

## How to use

In *exactly one* of your source file do:
In *exactly one* of your source files do:

```
#define NBNET_IMPL
#include "nbnet.h"
```

Provide a driver implementation. For the UDP driver, just add:
Provide a driver implementation. For instance, for the UDP driver, just add:

```
#include "net_drivers/udp.h"
Expand All @@ -125,7 +117,7 @@ nbnet does not provide any logging capabilities so you have to provide your own:
#define NBN_LogWarning(...) SomeLoggingFunction(__VA_ARGS__)
```

For memory management, nbnet uses `malloc`, `realloc` and `free`. You can redefine it using the following macros:
For memory management, nbnet uses `malloc`, `realloc` and `free`. You can redefine them if needed:

```
#define NBN_Allocator malloc
Expand Down Expand Up @@ -217,7 +209,7 @@ Just run:

in the directory containing your HTML file; then, open `http://localhost:8000` in your web browser and open your client HTML file.

One significant difference with running JS code in a web browser compared to running it in *NodeJS* is that you cannot use the *NodeJS* packaging system. nbnet's WebRTC code relies on *NodeJS* packages, so, for nbnet to run in a web browser we need to "bundle" those packages into something that can be used by a web browser.
One significant difference between running JS code in a web browser compared to running it in *NodeJS* is that you cannot use the *NodeJS* packaging system. nbnet's WebRTC code relies on *NodeJS* packages, so, for nbnet to run in a web browser we need to "bundle" those packages into something that can be used by a web browser.

I recommend using [browserify](https://github.com/browserify/browserify).

Expand Down

0 comments on commit ad2c3c3

Please sign in to comment.