Skip to content

Commit

Permalink
Update READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonrakena committed Dec 11, 2023
1 parent bd593de commit 7f4f425
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 82 deletions.
79 changes: 0 additions & 79 deletions Common/Networking/README.md

This file was deleted.

53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Promul is a simple, lightweight, and easy-to-use relay server and session management implementation for [Unity Netcode for GameObjects](https://docs-multiplayer.unity3d.com/netcode/current/about/).

Promul uses a heavily-modified version of the [LibNetLib](https://github.com/RevenantX/LiteNetLib) 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 [the networking documentation](Common/Networking/README.md).
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](https://unity.com/products/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.

Expand All @@ -25,8 +25,37 @@ Example:
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
### Protocol
Promul uses its own wire protocol over LibNetLib. The protocol is shown in the following diagram:
### Transit layer
Promul's included networking solution is a very heavily modified version of the amazing [LibNetLib](https://github.com/RevenantX/LiteNetLib) 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:
- The library requires .NET Standard 2.1.
- This limits the Unity versions that can use the library, but also
allows the library to use newer constructs such as `ArraySegment<T>`.
- The `NetDataReader` and `NetDataWriter` classes have been removed in favour of `BinaryReader` and `BinaryWriter` from `System.IO`.
- This means support for `INetSerializable` has been removed. Clients are expected to create extension overloads for `BinaryWriter.Write` and `BinaryReader.Read{Type}`.
- The logic and receive threads have been removed, in favour of a long-running `Task` spawned by the `NetManager`.
- Most of the library's blocking methods have been replaced with Task-based Asynchronous Programming (TAP) methods, using `Task`. This requires
a significant rewrite of most parts of the library.
- NAT punch-through and manual mode have both been removed.
- The transport will now put transport events onto a queue,
and `NetworkTransport#PollEvents` will dequeue events and pass them to Unity Netcode.
- `NetManager#Start` has been replaced by `PromulManager#ListenAsync`, which will begin infinitely looping, waiting for incoming messages.
- This method will block, so in the Unity transport, it is spawned on an un-awaited `Task`.
- Servers are expected to use a paradigm such as `BackgroundService` to run the long-running `Task`.
- Documentation has been improved.
- `NetPacket` no longer has jurisdiction over its data. It is a wrapper around an `ArraySegment<byte>`.
- Most (if not all) usages of `byte[] data, int offset, int count` have been replaced with `ArraySegment<byte>`.
- `INetBasedListener` and related classes have been removed. All events
are invoked on the `PromulManager` class as
regular CLR `event` types.
- In many classes, extraneous overloads have been removed in favour of default parameters.
### Protocol layer
Promul's Unity relay uses its own wire protocol over the transit layer. The protocol is shown in the following diagram:
```mermaid
sequenceDiagram
autonumber
Expand Down Expand Up @@ -59,6 +88,24 @@ sequenceDiagram
Host (ID 0)--xRelay: Connection lost
Relay->>Relay API: Destroys session
```

## Roadmap
### Engineering &mdash; Transit/Protocol
- [x] Task-based asynchronous programming rewrite
- [x] Authentication and binding tests
- [x] MTU negotation tests
- [ ] Replace logging with a better solution
- [ ] Restore merged sending support
- [ ] Restore NAT punch-through(?)
- [ ] Improve memory and throughput performance
- [ ] More real-world replications in tests
- [ ] More uses of `ValueTask<T>` over regular tasks
### Relay Server
- [x] Basic create/join session by join code
- [x] Update session manager
- [x] Basic web interface
- [ ] Further development of web interface
- [ ] Multicast(?)
## Copyright
&copy; 2023 Firework Eyes Studio (NZBN 9429048922678) under the MIT License.

Expand Down

0 comments on commit 7f4f425

Please sign in to comment.