Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Commit

Permalink
Update v5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek-R-S committed Jan 26, 2021
1 parent 8c34ca4 commit 450d7ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ In the config.json file there are a few fields.
TransportDLL - This is the name of the dll of the compiled transport dll.

TransportClass - The class name of the transport inside the DLL, Including namespaces!
By default, there are 3 compiled transports in the MultiCompiled dll.
By default, there are 4 compiled transports in the MultiCompiled dll.
To switch between them you have the following options:
* Mirror.LiteNetLibTransport
* Mirror.TelepathyTransport
* Mirror.SimpleWebTransport
* Mirror.MultiplexTransport

AuthenticationKey - This is the key the clients need to have on their inspector. It cannot be blank.

Expand Down
2 changes: 2 additions & 0 deletions ServerProject-DONT-IMPORT-INTO-UNITY/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public async Task MainAsync()
{
transport.ServerSend(_currentConnections[i], 0, new ArraySegment<byte>(new byte[] { 200 }));
}

GC.Collect();
}

await Task.Delay(conf.UpdateLoopTime);
Expand Down
12 changes: 10 additions & 2 deletions UnityTransport/LightReflectiveMirrorTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class LightReflectiveMirrorTransport : Transport
public float heartBeatInterval = 3;
public bool connectOnAwake = true;
public string authenticationKey = "Secret Auth Key";
public UnityEvent diconnectedFromRelay;
[Header("Server Hosting Data")]
public string serverName = "My awesome server!";
public string extraServerData = "Map 1";
Expand Down Expand Up @@ -49,12 +50,19 @@ private void Awake()
InvokeRepeating(nameof(SendHeartbeat), heartBeatInterval, heartBeatInterval);
}

private void OnEnable()
{
clientToServerTransport.OnClientConnected = ConnectedToRelay;
clientToServerTransport.OnClientDataReceived = DataReceived;
clientToServerTransport.OnClientDisconnected = Disconnected;
}

void Disconnected() => diconnectedFromRelay?.Invoke();

public void ConnectToRelay()
{
if (!_connectedToRelay)
{
clientToServerTransport.OnClientConnected = ConnectedToRelay;
clientToServerTransport.OnClientDataReceived = DataReceived;
_clientSendBuffer = new byte[clientToServerTransport.GetMaxPacketSize()];

clientToServerTransport.ClientConnect(serverIP);
Expand Down

0 comments on commit 450d7ba

Please sign in to comment.