Update v5.0

This commit is contained in:
Derek 2021-01-26 17:04:31 -06:00
parent 8c34ca4756
commit 450d7ba309
3 changed files with 14 additions and 3 deletions

View file

@ -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. 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! 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: To switch between them you have the following options:
* Mirror.LiteNetLibTransport * Mirror.LiteNetLibTransport
* Mirror.TelepathyTransport * Mirror.TelepathyTransport
* Mirror.SimpleWebTransport * Mirror.SimpleWebTransport
* Mirror.MultiplexTransport
AuthenticationKey - This is the key the clients need to have on their inspector. It cannot be blank. AuthenticationKey - This is the key the clients need to have on their inspector. It cannot be blank.

View file

@ -119,6 +119,8 @@ namespace LightReflectiveMirror
{ {
transport.ServerSend(_currentConnections[i], 0, new ArraySegment<byte>(new byte[] { 200 })); transport.ServerSend(_currentConnections[i], 0, new ArraySegment<byte>(new byte[] { 200 }));
} }
GC.Collect();
} }
await Task.Delay(conf.UpdateLoopTime); await Task.Delay(conf.UpdateLoopTime);

View file

@ -16,6 +16,7 @@ namespace LightReflectiveMirror
public float heartBeatInterval = 3; public float heartBeatInterval = 3;
public bool connectOnAwake = true; public bool connectOnAwake = true;
public string authenticationKey = "Secret Auth Key"; public string authenticationKey = "Secret Auth Key";
public UnityEvent diconnectedFromRelay;
[Header("Server Hosting Data")] [Header("Server Hosting Data")]
public string serverName = "My awesome server!"; public string serverName = "My awesome server!";
public string extraServerData = "Map 1"; public string extraServerData = "Map 1";
@ -49,12 +50,19 @@ namespace LightReflectiveMirror
InvokeRepeating(nameof(SendHeartbeat), heartBeatInterval, heartBeatInterval); InvokeRepeating(nameof(SendHeartbeat), heartBeatInterval, heartBeatInterval);
} }
private void OnEnable()
{
clientToServerTransport.OnClientConnected = ConnectedToRelay;
clientToServerTransport.OnClientDataReceived = DataReceived;
clientToServerTransport.OnClientDisconnected = Disconnected;
}
void Disconnected() => diconnectedFromRelay?.Invoke();
public void ConnectToRelay() public void ConnectToRelay()
{ {
if (!_connectedToRelay) if (!_connectedToRelay)
{ {
clientToServerTransport.OnClientConnected = ConnectedToRelay;
clientToServerTransport.OnClientDataReceived = DataReceived;
_clientSendBuffer = new byte[clientToServerTransport.GetMaxPacketSize()]; _clientSendBuffer = new byte[clientToServerTransport.GetMaxPacketSize()];
clientToServerTransport.ClientConnect(serverIP); clientToServerTransport.ClientConnect(serverIP);