HouraiTeahouse / HouraiNetworking

Transport level library for peer-to-peer networking with multiple backends for the Unity.
MIT License
100 stars 16 forks source link
peer-to-peer relay-networks transport unity

Hourai Networking

Platform based P2P networking with multiple backends.

Features

Supported Backends

Hourai Networking acts as a wrapper around these backends to provide support. Some features may not be uniform across all platforms.

Feature Steam Discord Direct UDP Epic Games
Implemenation ✔️ ✔️ Planned Planned
Lobbies ✔️ ✔️ ?
Matchmaking ✔️ ✔️ ?
Custom Metadata ✔️ ✔️ ? ?
Host Migration ✔️ ✔️ ? ?
Windows Support ✔️ ✔️ ? ?
MacOS Support ✔️ ✔️ ? ?
Linux Support ✔️ ✔️ ? ?

Installation

Backroll is most easily installable via Unity Package Manager. In Unity 2018.3+, add the following to your Packages/manifest.json:

{
  "dependencies": {
    "com.houraiteahouse.networking": "0.1.1"
  },
  "scopedRegistries": [
    {
      "name": "Hourai Teahouse",
      "url": "https://upm.houraiteahouse.net",
      "scopes": ["com.houraiteahouse"]
    }
  ]
}

FAQ:

Q: Why peer-to-peer? Almost everyone uses client-server nowadays!

There are notable issues with peer-to-peer networking:

These are notable issues commonly seen, which is why the majority of the game industry nowadays aims for an authoritative client-server model of netplay. However, the main argument against this model, espeically for low-budget games that want netplay, is cost. Running a fleet of servers 24/7, and paying operators to maintain those servers is simply impossible for most small developers.

Peer-to-peer netwroking only requires multiple players to share the same game version and an internet connection. No dedicated servers are required on the developer's end.

Q: Why use proprietary networks like Steam and Discord?

One of the aforementioned issues with peer-to-peer networking is the inconsistent connection issues. Modern consumer home networks are almost always behind NATs (network address translation), which makes normal socket based connections almost impossible without a whole host of hacks and workarounds (i.e. UPnP, libjingle, STUN, etc.), none of which are perfect. The only true way to ensure connections complete is to have a relay server network, with well known public IPs. This returns to the issues of servers and cost. Luckily, Steam and Discord, now some of the largest companies in PC gaming, offer free access their relay networks to developers willing to integrate with their systems: allowing for more consistent netplay experience in exchange for some vendor lock-in. One of the goals of HouraiNetworking is to help allievate that vendor lock-in by abstracting platform level differences away.

One other benefit to these solutions is use of relay services often incorproates IP masking and encryption to help maintian player privacy.