jacksonrakena / promul

An open-source networking & relay implementation for Unity Netcode for GameObjects
33 stars 2 forks source link
netcode-for-gameobjects relay relay-server unity unity-multiplayer unity-netcode

Promul

Promul is a simple, lightweight, and easy-to-use relay server and session management implementation for Unity Netcode for GameObjects.

Promul is designed to quickly allow independent and small developers to have fully functional peer-to-peer (P2P) gameplay over top of an open-source relay server, allowing players to play together without complicated port-forwarding configurations, and with minimal infrastructure investment and expenditure for the development team.

It works by providing a relay server and wire protocol for clients, allowing players to both host and join games using Unity's Netcode for GameObjects library. It ships with its own UDP-based networking solution, which can be used independently of the relay protocol.

Promul uses a heavily-modified version of the LibNetLib library for its internal networking, converting the library from a thread-based non-async model to a Task-based Asynchronous Programming (TAP)-based implementation. Technical details of the networking are explained in engineering section below.

Promul is intended to be a free and open-source alternative to Unity Relay. It supports join secret-based session management, with a REST API for creating and deleting sessions, and an admin UI for managing active sessions.

Setup

Relay server and API

Clone this repository and build and run the program under /Server. The relay server will bind on UDP port 4098 while the API server will bind on TCP port 3000.

To create a new session, call PUT /session/create. The API will respond with the join code.

Relay client (Transport)

Install the transport by adding it in the Unity Package Manager by git URL:
https://github.com/jacksonrakena/Promul.git

Next, add PromulTransport to your NetworkManager GameObject. Set the Address and Port to the address and port of your relay server.

Example:
Alt text

You should now be ready to use Promul as a relay server for your Unity project. You can call NetworkManager's StartHost/StartClient/StartServer methods as normal.

Engineering

flowchart TD
    subgraph Unity
    Code[Your Unity code] -->|Unity Netcode| Runtime[Promul.Runtime.Unity]
    end

    subgraph Unreal Engine
    UECode[Your UE code] --> RuntimeUE["Promul.Runtime.Unreal\n(planned)"]
    end

    subgraph "Protocol layer"
    Protocol[Promul.Relay.Protocol]
    end
    Protocol-->Core
    Runtime-->Protocol
        RuntimeUE-->Protocol

    subgraph Relay server
    API[Promul.Server.API\nFront-facing]-->Server[Promul.Server]
    Server-->Protocol
    end

    subgraph Transit layer
    Core[Promul\nKey networking capabilities]
    Core-->Native[Native sockets]
    Core-->Managed[Managed sockets]
    end

Transit layer

Promul's included networking solution is a very heavily modified version of the amazing LibNetLib by Ruslan Pyrch.

Promul is probably compatible with LibNetLib clients and servers. I don't know, and I don't check.
Compatibility with LibNetLib is not a goal of Promul.

Differences from LibNetLib

Among other differences:

Roadmap

Engineering — Transit/Protocol

This project uses a heavily modified version of LibNetLib.
LiteNetLib © 2020 Ruslan Pyrch, under the following license:

MIT License

Copyright (c) 2020 Ruslan Pyrch

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.