Browse Source

Documentation cleanup

Nothing to see here, just the usual clean up...
Matt Coburn 5 years ago
parent
commit
f393d53a7c
3 changed files with 80 additions and 53 deletions
  1. 3 0
      CHANGES.md
  2. 10 4
      COMMON-MISTAKES.md
  3. 67 49
      README.md

+ 3 - 0
CHANGES.md

@@ -0,0 +1,3 @@
+## Changes in this fork compared to upstream's fork
+
+TODO.

+ 10 - 4
COMMON-MISTAKES.md

@@ -8,12 +8,14 @@ Never dispose a packet after enqueuing it for sending, ENet does that for you au
 
 ### `Packet.Dispose()` called more than once per received packet.
 
-The `Packet` structure is a value type thus internal checks will fail for two different copies of a packet, and a memory access failure will occur. Try to keep processing flow under strict control. If the received packet will be sent further, you should not dispose it since ENet will use it as you normally enqueuing a packet for sending.
+The `Packet` structure is a value type thus internal checks will fail for two different copies of a packet and a memory access failure will occur. Try to keep processing flow under strict control. If the received packet will be sent further, you should not dispose it since ENet will use it as you normally enqueuing a packet for sending.
 
 ### Channels limit didn't match at the endpoints.
 
 Always make sure that the channel limit set to the same value at the endpoints using `Host.Create()` and `Host.Connect()` functions. Failure to do so otherwise results in packets will not be delivered on disabled channels.
 
+Example: If the server has 10 channels, but the client only has 8 specified, packets channels 9 and 10 will not be accepted.
+
 ### Round-trip time is unstable even on localhost.
 
 This is the first indication that the `Host.Service()` is not called often enough. Make sure that the service and events are processed continuously and nothing prevents the ENet to shuttle packets across peers.
@@ -24,9 +26,11 @@ Make sure that only the actual payload is sent and not a whole buffer, a packet
 
 ### A host is unable to accept multiple connections or degrades with many packets.
 
-Make sure that the service is processing as many events as possible and not only one event per frame/iteration. Put the service into a loop even within a game loop (but without a timeout to avoid blocking). Utilizing C# Threads can help too.
+Make sure that the service is processing as many events as possible and not only one event per frame/iteration. Put the service into a loop even within a game loop (but without a timeout to avoid blocking). 
+
+Example: If using the Unity Engine, you can carefully put Enet into it's own C# thread. This decouples Enet away from the Unity main loop.
 
-If nothing helps, you can try to increase the socket buffer size of the host up to one megabyte using the appropriate parameter at both ends.
+If nothing helps, you can try to increase the socket buffer size of the [host](https://github.com/SoftwareGuy/ENet-CSharp/DOCUMENTATION.md#host) up to one megabyte using the appropriate parameter at both ends.
 
 ### A host is not flushed after the service is no longer in a loop.
 
@@ -34,6 +38,8 @@ Always flush the host before the end of a session to ensure that all queued pack
 
 ### Unreliable packets are dropped significantly under simulation of latency.
 
-If the simulated delay/ping is applied in the middle of the process, but not before connection establishment, then unreliable packets will be throttled if simulated latency exceeds the threshold (20 ms by default between service updates). See the description of `Peer.ConfigureThrottle()` [here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/DOCUMENTATION.md) for details and parameters tuning.
+If the simulated delay/ping is applied in the middle of the process but not before connection establishment, then unreliable packets will be throttled if simulated latency exceeds the threshold (20 ms by default between service updates). 
+
+See the description of `Peer.ConfigureThrottle()` [here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/DOCUMENTATION.md#peer) for details and parameters tuning.
 
 This document will be updated as time goes on.

+ 67 - 49
README.md

@@ -10,86 +10,109 @@
 _**Please consider a donation (see the Ko-Fi button above) if this project is useful to you.**_
 
 ## What's this?
-This is a improved/refactored version of ENet-CSharp, forked from another ENet fork. Due to unfortunate circumstances between two development entities, the upstream repository was archived and is only updated when patches are applied (all development work is done in private). Since you cannot interact with archived repositories outside of code-related things, this repository acts as a workaround to those issues.
 
-In short, this is an independent ENet implementation with a modified protocol for C, C++, C#, and other languages. The original C library both forks are based on can be found [here](https://github.com/lsalzman/enet).
+In short, this is an independent ENet native implementation with a modified protocol for C, C++, C#, and other languages.
+The original C library both this fork and upstreams' fork is based on is located [here](https://github.com/lsalzman/enet).
 
-Unlike the upstream repository code of conduct where issue tickets were closed randomly for no reason, if you have a problem with ENet-CSharp, we'll be able to investigate. We also have a proper implementation of the `ENET_DEBUG` definition, allowing logging output to be written to `enet_log.txt` for further diagnosis and troubleshooting. Code cleanups and optimizations for better performance are included, and if someone files a supposedly-a-bug tickets actually get analyzed and if it's really a bug, it'll get fixed.
+A slightly longer description is that this is a improved and refactored version of ENET-CSharp. A fork of a fork, if you want to call it that. This fork started since the upstream fork was originally archived, disabling the ability to report issues and submit pull requests.
+The upstream developer also made some questionable choices (including blacklisting/blocking myself and numerous others). As a result, this fork was made and allows developers to ask questions and submit pull requests to improve the implementation.
 
-## Compatibility with Upstream
-Don't use the upstream releases with the code in this repository. You will most likely get crashes or weird things happening.
+## Native Library Features
+
+- Lightweight and straightforward
+- Low resource consumption
+- Dual-stack IPv4/IPv6 support
+- Connection management, Sequencing, Channels, Reliability, Fragmentation, Reassembly
+- Aggregation
+- Adaptability and portability
+
+## Upstream Compatibility
+
+Do not use the upstream binaries with this fork. While it *may* work, it is best to err on the side of caution and play it safe.
+
+## Obtaining the native libraries
 
-## Building your own binaries
-If you don't want to take the automatically built libraries in the releases section, you can use the Visual Studio MSBuild engine to build if you like. However the following will be oriented for power users and command line heroes, and requires NET Core SDK 2.2 to work correctly.
+### Easy Mode
 
-### Desktop Compile
+You can get precompiled binaries for use with this fork by checking out the [Releases](https://github.com/SoftwareGuy/ENet-CSharp/releases) page.
 
-- **Windows:** Make sure you have Visual Studio 2017/2019 installed with the C++ Support bundle ticked, a recent Windows 10 SDK and CMake. CMake sometimes doesn't get automatically installed with Visual Studio, so you may need to grab it manually from Kitware's website. Ensure it's a recent version (anything 3.16+ works).
+### Hard Mode
 
-- **MacOS:** Make sure you have Apple Xcode CLI Tools installed (Xcode might also be required for the MacOS SDK).
+If you don't want to take the automatically built libraries in the releases section, you can use the Visual Studio MS Build engine to build a binary for your platform(s).
 
-- **Linux:** Make sure you have your repositories' `build-essential` and `cmake` package installed. On Debian and Ubuntu-based distros, you can do `sudo apt -y build-essential cmake` to install the required things.
+However the following will be oriented for power users and command line heroes, and requires NET Core SDK 2.2 to work correctly.
 
-### Mobile 
+#### Compiling for Desktop
+
+- **Windows:** Make sure you have Visual Studio '17 or '19 installed with C++ Development Support, a recent Windows SDK and CMake. You may need to install [CMake from Kitware](https://cmake.org/download/) as it *sometimes* doesn't get automatically installed with Visual Studio. Version 3.16 or newer works fine.
+
+- **MacOS:** You'll need Xcode (available from the Mac App Store or the Apple Developer Portal). Make sure you also have Apple Xcode CLI Tools installed.
+
+- **Linux:** Make sure you have your repositories' `build-essential` and `cmake` package installed. On Debian and Ubuntu-based distros, you can do `sudo apt -y build-essential cmake` to install the required packages.
+
+#### Compiling for Mobile
 
 - **Android:** Ensure you have the Android NDK installed. Easiest way to do this to go into `Sources/Native` and run when `ndk-build`. A fresh batch of ENET binaries should then be spat out, which can be used in your project.
 
 - **Apple iOS:** Using **Terminal.app** on your MacOS device, navigate to the `Build-iOS` directory and run the command file found inside. You might need to make it executable, however. It will try to auto-pilot a build for you, just make sure you have CMake installed for MacOS and a recent Xcode installation. Library code signing will be disabled for the build.
 
-### Console
-- **Nintendo Switch:** A old guide is available [here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/BUILD-FOR-SWITCH.txt). However, it will require some modification to work with the Switch OS and Nintendo's own SDK. Since said SDK is under NDA, limited public info can be provided.
+#### Compiling for Console
+
+- **Microsoft Xbox One:** Limited testing says the Windows library should work fine, unless the Windows-based Xbox OS uses a different SDK. However, I do not have access to an XB1 Developer Kit.
+
+- **Nintendo Switch:** A old guide is available [here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/BUILD-FOR-SWITCH.txt). However, it will require patches to work with the Switch SDK. Since said SDK is under NDA, limited public info can be provided.
 
-- **Playstation 4/Vita:** An Vita port exists already, however I am not planning to add support for the Vita to this repository. PS4 is obviously no go as well.
+- **Playstation 4/Vita:** I am not planning to add support for the PS4/PSVita to this repository. The native layer will most likely require patches to use on Sony's BSD-based PlayStation OS.
 
 - **Other console not listed:** Open a issue ticket and I'll gladly add your steps for your platform here.
 
-### Recipe for victory
+#### Recipe for victory
+
 - Clone a fresh copy of this Git Repo somewhere on your workstation's filesystem.
 - Open a command prompt/terminal and change directory into the newly cloned git repository.
 - Run `dotnet build`. 
+- **Protip:** You can append `-c Release` or `-c Debug` to your `dotnet build` command to build a release binary or a debug binary of ENET's C library. At the moment, the default build is a Debug build.
 
-**Protip:** You can append `-c Release` or `-c Debug` to your `dotnet build` command to build a release binary or a debug binary of ENET's C library. At the moment, the default build is a Debug build.
-
-You will see an anime babe appear followed by [Ignorance](https://github.com/SoftwareGuy/Ignorance) ASCII art. Thanks to c6 for that eyecandy!
+You will see [Ignorance](https://github.com/SoftwareGuy/Ignorance) ASCII art fly by and the compile will start. CMake will fire up, configure itself after inspecting your build environment and hopefully spit out a binary blob inside a `Unity/Plugins` directory. 
 
-CMake will fire up, configure itself after inspecting your build environment and hopefully spit out a binary blob inside a `Unity/Plugins` directory. On Windows, this will be a DLL, on Mac it will be a `.bundle` file and on Linux it will be a shared object (`.so`). This can be used with Unity or other applications like a C# NET Core application or C/C++ app.
+On Windows, this freshly baked library will be a DLL, on Mac it will be a `.bundle` file and on Linux it will be a shared object (`.so`). This can be used with Unity or other applications like a C# NET Core application or C/C++ apps.
 
-## Testing
-- `dotnet test` will run some sanity checks and make sure ENET initializes, data is received and sent correctly, etc.
+#### Rebuilding the native binaries
 
-## Rebuilding
 Inside the directory that you cloned the repo to, run:
+
 - `dotnet clean`
 - `dotnet build` (don't forget about the `-c Release/Debug` argument as mentioned earlier!)
 
 It is recommended to clean the repository work space before building.
 
-## Native Library Features
-- Lightweight and straightforward
-- Low resource consumption
-- Dual-stack IPv4/IPv6 support
-- Connection management, Sequencing, Channels, Reliability, Fragmentation, Reassembly
-- Aggregation
-- Adaptability and portability
+### Testing
+
+- `dotnet test` will run some sanity checks and make sure ENET initializes, data is received and sent correctly, etc.
 
 ## Usage
+
+
 - Initialize ENET first before doing anything by calling the `ENet.Library.Initialize();` function. It will return false on failure, return true on success. You can use this to gracefully quit your application should it fail to initialize, for example.
 - Once you are done, deinitialize the library using `ENet.Library.Deinitialize();` function.
-
-### ENet-CSharp with Unity
-Usage is almost the same as in the .NET environment, except that the console functions must be replaced with functions provided by Unity. If the `Host.Service()` will be called in a game loop, then make sure that the timeout parameter set to 0 which means non-blocking. Also make sure Unity runs in the background by enabling the ***Run in Background*** player setting.
+- Unity Engine usage is almost the same as in the .NET environment, except that the console functions must be replaced with functions provided by Unity. If the `Host.Service()` will be called in a game loop, then make sure that the timeout parameter set to 0 which means non-blocking. Also make sure Unity runs in the background by enabling the ***Run in Background*** player setting.
 
 ### Code Examples/Quick Start
-A good idea is to check out the [common mistakes during integration](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/COMMON-MISTAKES.md) documentation. Looking for example code and gotta go fast? No problem, got you [covered here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/QUICKSTART-EXAMPLES.md).
 
-## Multi-threading
+A good idea is to check out the [common mistakes during integration](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/COMMON-MISTAKES.md) documentation. 
+
+Looking for example code and gotta go fast? No problem, got you [covered here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/QUICKSTART-EXAMPLES.md).
+
+## API Documentation
+
+See `DOCUMENTATION.md` [here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/DOCUMENTATION.md).
+
+## Enet and multi-threading
+
 ### Strategy
 The best-known strategy is to use ENet in an independent I/O thread. This can be achieved by using Threads and enqueuing packets to be sent and received back and forth via ConcurrentQueues, for example. RingBuffers and Disruptors are also solid performance options too. Use whatever queue system you feel comfortable with, just make sure you empty the queues as fast as possible in your applications.
 
-A real world example is Oiran Studio's [Ignorance](https://github.com/SoftwareGuy/Ignorance) transport which uses this ENET-CSharp fork via a Threaded Implementation to ensure the network threads run as fast as ENET can pump.
-
-### Unity Warning
-Threading in Unity was problematic but later versions (2018.3+) have proven to be fine. Please beware that using Threads inside a Unity environment can be problematic and can lead to the Unity Editor or built games randomly crashing without any warning. Use them with caution!
+A real world example is Oiran Studio's [Ignorance](https://github.com/SoftwareGuy/Ignorance) transport which uses ConcurrentQueues for high performance transport I/O.
 
 ### Thread Safety
 In general, ENet is not thread-safe, but some of its functions can be used safely if the user is careful enough:
@@ -100,13 +123,10 @@ In general, ENet is not thread-safe, but some of its functions can be used safel
 
 - `Library.Time`: utilizes atomic primitives internally for managing local monotonic time.
 
-### API Documentation
---------
-See `DOCUMENTATION.md` [here](https://github.com/SoftwareGuy/ENet-CSharp/blob/master/DOCUMENTATION.md).
 
 ### Supporters
---------
-This fork is used by and supported by [Oiran Studio](http://www.oiran.studio).
+
+This fork is supported, used, mantained and supported by [Oiran Studio](http://www.oiran.studio).
 
 <p align="left"> 
   <img src="http://www.oiran.studio/OiranFanFinal_Colour_Mini.png" alt="Oiran Studio Logo">
@@ -118,8 +138,6 @@ This fork is used by and supported by [Oiran Studio](http://www.oiran.studio).
 - c6burns
 - Katori
 - Mirror Team & Discord Members
-
-#### Some thanks to:
-- Vincenzo from Flying Squirrel Entertainment
-- lsalzman for the original enet repository
-- nxrighthere
+- Vincenzo from Flying Squirrel Entertainment ("resident enet guy")
+- lsalzman for the original Enet native repository
+- nxrighthere for the upstream fork