Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs and sln files #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
3 changes: 0 additions & 3 deletions MLAPI.Relay.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MLAPI.Relay", "MLAPI.Relay\MLAPI.Relay.csproj", "{987C1675-41A5-4587-AAC4-F44C2621E337}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{764D72F2-52B9-4EB8-8FF6-5AB4D65CBE2A}"
ProjectSection(SolutionItems) = preProject
RelayTransport.cs = RelayTransport.cs
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLAPI.Relay.Transports", "MLAPI.Relay.Transports\MLAPI.Relay.Transports.csproj", "{19F173D4-3166-46CD-9A00-FE0CC7E3AA5A}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion MLAPI.Relay/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Client
{
public bool IsServer { get; set; }
public ulong ConnectionId { get; set; }
public bool IsInBandwidthGracePeriod => (DateTime.UtcNow - ConnectTime).TotalSeconds >= Program.Config.BandwidthGracePrediodLength;
public bool IsInBandwidthGracePeriod => (DateTime.UtcNow - ConnectTime).TotalSeconds >= Program.Config.BandwidthGracePeriodLength;
public DateTime ConnectTime { get; set; }
public ulong OutgoingBytes { get; set; }
}
Expand Down
7 changes: 7 additions & 0 deletions MLAPI.Relay/MLAPI.Relay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<FileVersion>0.0.0.2</FileVersion>
<Version>1.0.0.0</Version>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down Expand Up @@ -46,4 +47,10 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Budtom marked this conversation as resolved.
Show resolved Hide resolved
<None Update="UNETServerDLL.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions MLAPI.Relay/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static void Main(string[] args)
Transport = TransportType.UNET,
AllowTemporaryAlloc = true,
MaxTemporaryAlloc = 1024 * 16,
BandwidthGracePrediodLength = 60 * 2,
BandwidthGracePeriodLength = 60 * 2,
BandwidthLimit = -1,
EnableRuntimeMetaLogging = true,
GracePeriodBandwidthLimit = -1,
Expand All @@ -97,7 +97,7 @@ private static void Main(string[] args)
Transport = TransportType.UNET,
BufferSize = 1024 * 8,
AllowTemporaryAlloc = true,
BandwidthGracePrediodLength = 60 * 2,
BandwidthGracePeriodLength = 60 * 2,
BandwidthLimit = -1,
EnableRuntimeMetaLogging = true,
GracePeriodBandwidthLimit = -1,
Expand All @@ -115,7 +115,7 @@ private static void Main(string[] args)
Transport = TransportType.UNET,
BufferSize = 1024 * 8,
AllowTemporaryAlloc = true,
BandwidthGracePrediodLength = 60 * 2,
BandwidthGracePeriodLength = 60 * 2,
BandwidthLimit = -1,
EnableRuntimeMetaLogging = true,
GracePeriodBandwidthLimit = -1,
Expand All @@ -136,7 +136,7 @@ private static void Main(string[] args)
{
Transport = TransportType.Ruffles,
AllowTemporaryAlloc = true,
BandwidthGracePrediodLength = 60 * 2,
BandwidthGracePeriodLength = 60 * 2,
BandwidthLimit = -1,
BufferSize = 1024 * 8,
EnableRuntimeMetaLogging = true,
Expand Down
4 changes: 2 additions & 2 deletions MLAPI.Relay/RelayConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ namespace MLAPI.Relay
public class RelayConfig
{
[JsonConverter(typeof(StringEnumConverter))]
public TransportType Transport = TransportType.Ruffles;
public TransportType Transport = TransportType.UNET;
public object TransportConfig;
public ushort BufferSize = 1024 * 8;
public bool EnableRuntimeMetaLogging = true;
public int BandwidthGracePrediodLength = 60;
public int BandwidthGracePeriodLength = 60;
public int GracePeriodBandwidthLimit = 4000;
public int BandwidthLimit = 2000;
public bool AllowTemporaryAlloc = true;
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,18 @@ Relay config contains many different fields:
* **bandwidthGracePeriodLength** is the length of the bandwidth grace period from the point when a client connects.
* **gracePeriodBandwidthLimit** is the amount of bytes per second that is allowed during the bandwidth grace period for each client. If this 0 or less, the traffic will not be limited during the grace period.
* **bandwidthLimit** is the amount of bytes per second that is allowed for each client after their respective the grace periods. If this is 0 or less, no limit will be set.

### Quickstart Guide

See below for a basic setup guide for building and deploying the MLAPI relay to a Amazon EC2 instance (Free tier - Windows server 2012)

* Clone the repository
* Open the MLAPI.Relay.sln file inside an IDE (Visual Studio 2019)
* Build the release, following the onscreen prompts for the required config
* Copy the contents of the build directory i.e. bin\release onto the Amazon EC2 instance
* Install dotnet-sdk-2.2.402-win-x64.exe on the server - https://dotnet.microsoft.com/download/dotnet-core/2.2
* Run "dotnet MLAPI.Relay.dll" in the Release\netcoreapp2.0 folder to start the server
* Ensure that firewall rules for inbound and outbound traffic have been setup to allow connections for your desired port (default 8888)
* Ensure the EC2 instance has the correct security settings to allow connections from any IPs you wish to connect to the server

Now you should be ready to connect to the server from unity. This can be achieved with MLAPI by creating an empty game object with the NetworkingManager script (adding the UNET transport) and configuring the settings to match the config.json settings used in the relay. The connect address should be your normal player hosted server address, the relay address should be the address to the relay (has to be set on both client and server). Then enable relaying and use NetworkingManager.Singleton.StartHost() on the Server and NetworkingManager.Singleton.StartClient() on the client and they should connect to the relay.