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

Commit

Permalink
Update v6
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek-R-S committed Feb 17, 2021
1 parent 450d7ba commit a57b481
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ Light Reflective Mirror has a built in room/server list if you would like to use

To request the server list you need a reference to the LightReflectiveMirrorTransport from your script and call 'RequestServerList()'. This will invoke a request to the server to update our server list. Once the response is recieved the field 'relayServerList' will be populated and you can get all the servers from there.

#### Free Relay
Note: If you would like to test without creating a server, feel free to use my test server with IP: 34.67.125.123. Which is in there by default :)

#### Server Setup
Download the latest Server release from: [Releases](https://github.com/Derek-R-S/Light-Reflective-Mirror/releases)
Make sure you have .NET Core 3.1
Expand Down
9 changes: 8 additions & 1 deletion UnityTransport/LightReflectiveMirrorTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class LightReflectiveMirrorTransport : Transport
private bool _isServer = false;
private bool _isAuthenticated = false;
private int _currentMemberId;
private bool _callbacksInitialized = false;
private BiDictionary<int, int> _connectedRelayClients = new BiDictionary<int, int>();
public bool IsAuthenticated() => _isAuthenticated;

Expand All @@ -44,14 +45,20 @@ private void Awake()
throw new Exception("Haha real funny... Use a different transport.");
}

SetupCallbacks();

if (connectOnAwake)
ConnectToRelay();

InvokeRepeating(nameof(SendHeartbeat), heartBeatInterval, heartBeatInterval);
}

private void OnEnable()
private void SetupCallbacks()
{
if (_callbacksInitialized)
return;

_callbacksInitialized = true;
clientToServerTransport.OnClientConnected = ConnectedToRelay;
clientToServerTransport.OnClientDataReceived = DataReceived;
clientToServerTransport.OnClientDisconnected = Disconnected;
Expand Down

0 comments on commit a57b481

Please sign in to comment.