diff --git a/README.md b/README.md index e77c05c..f1883e9 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Program.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/Program.cs index 166470c..23f6117 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/Program.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/Program.cs @@ -119,6 +119,8 @@ namespace LightReflectiveMirror { transport.ServerSend(_currentConnections[i], 0, new ArraySegment(new byte[] { 200 })); } + + GC.Collect(); } await Task.Delay(conf.UpdateLoopTime); diff --git a/UnityTransport/LightReflectiveMirrorTransport.cs b/UnityTransport/LightReflectiveMirrorTransport.cs index ccc8339..ea33aed 100644 --- a/UnityTransport/LightReflectiveMirrorTransport.cs +++ b/UnityTransport/LightReflectiveMirrorTransport.cs @@ -16,6 +16,7 @@ namespace LightReflectiveMirror 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"; @@ -49,12 +50,19 @@ namespace LightReflectiveMirror 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);