Settings Screen init

This commit is contained in:
Sewmina Dilshan
2021-09-05 18:13:50 +05:30
parent 3b91175811
commit a7f0895fa9
630 changed files with 164840 additions and 6951 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using kcp2k;
@@ -761,8 +762,20 @@ namespace Mirror
// it will be re-enabled in FinishLoadScene.
NetworkServer.isLoadingScene = true;
StartCoroutine(loadScene(newSceneName));
}
IEnumerator loadScene(string newSceneName)
{
loadingSceneAsync = SceneManager.LoadSceneAsync(newSceneName);
while (!loadingSceneAsync.isDone)
{
yield return null;
}
// ServerChangeScene can be called when stopping the server
// when this happens the server is not active so does not need to tell clients about the change
if (NetworkServer.active)

View File

@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using UnityEngine;
using UnityEngine.Networking;
@@ -19,6 +20,7 @@ namespace LightReflectiveMirror
IEnumerator RelayConnect()
{
string url = $"http://{loadBalancerAddress}:{loadBalancerPort}/api/join/";
serverStatus = "Waiting for LLB...";
using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
@@ -31,8 +33,14 @@ namespace LightReflectiveMirror
webRequest.SetRequestHeader("Access-Control-Allow-Origin", "*");
yield return webRequest.SendWebRequest();
var result = webRequest.downloadHandler.text;
// var result = webRequest.downloadHandler.text;
WebClient client = new WebClient();
client.Proxy = null;
var result = client.DownloadString(url);
var parsedAddress = JsonUtility.FromJson<RelayAddress>(result);
Connect(parsedAddress.address, parsedAddress.port);
endpointServerPort = parsedAddress.endpointPort;
if (false) {
#if UNITY_2020_1_OR_NEWER
switch (webRequest.result)
{
@@ -42,9 +50,9 @@ namespace LightReflectiveMirror
Debug.LogWarning("LRM | Network Error while getting a relay to join from Load Balancer.");
break;
case UnityWebRequest.Result.Success:
var parsedAddress = JsonUtility.FromJson<RelayAddress>(result);
Connect(parsedAddress.address, parsedAddress.port);
endpointServerPort = parsedAddress.endpointPort;
// var parsedAddress = JsonUtility.FromJson<RelayAddress>(result);
// Connect(parsedAddress.address, parsedAddress.port);
// endpointServerPort = parsedAddress.endpointPort;
break;
}
#else
@@ -60,7 +68,8 @@ namespace LightReflectiveMirror
endpointServerPort = parsedAddress.endpointPort;
}
#endif
}
}
}
}
IEnumerator JoinOtherRelayAndMatch(Room? roomValue, string ID)
@@ -130,30 +139,43 @@ namespace LightReflectiveMirror
using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
{
// webRequest.
webRequest.SetRequestHeader("Access-Control-Allow-Credentials", "true");
webRequest.SetRequestHeader("Access-Control-Allow-Headers", "Accept, X-Access-Token, X-Application-Name, X-Request-Sent-Time");
webRequest.SetRequestHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
webRequest.SetRequestHeader("Access-Control-Allow-Origin", "*");
// webRequest.SetRequestHeader("Proxy-Authorization", "");
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
var result = webRequest.downloadHandler.text;
// var result = webRequest.downloadHandler.text;
#if UNITY_2020_1_OR_NEWER
switch (webRequest.result)
WebClient client = new WebClient();
client.Proxy = null;
var result = client.DownloadString(uri);
// Debug.Log(result);
Debug.Log(client.DownloadString(uri));
relayServerList?.Clear();
relayServerList = JsonUtilityHelper.FromJson<Room>(result.Decompress()).ToList();
serverListUpdated?.Invoke();
if (false)
{
case UnityWebRequest.Result.ConnectionError:
case UnityWebRequest.Result.DataProcessingError:
case UnityWebRequest.Result.ProtocolError:
Debug.LogWarning("LRM | Network Error while retreiving the server list!");
break;
#if UNITY_2020_1_OR_NEWER
switch (webRequest.result)
{
case UnityWebRequest.Result.ConnectionError:
case UnityWebRequest.Result.DataProcessingError:
case UnityWebRequest.Result.ProtocolError:
Debug.LogWarning("LRM | Network Error while retreiving the server list!");
break;
case UnityWebRequest.Result.Success:
relayServerList?.Clear();
relayServerList = JsonUtilityHelper.FromJson<Room>(result.Decompress()).ToList();
serverListUpdated?.Invoke();
break;
}
case UnityWebRequest.Result.Success:
relayServerList?.Clear();
relayServerList = JsonUtilityHelper.FromJson<Room>(result.Decompress()).ToList();
serverListUpdated?.Invoke();
break;
}
#else
if (webRequest.isNetworkError || webRequest.isHttpError)
{
@@ -166,6 +188,7 @@ namespace LightReflectiveMirror
serverListUpdated?.Invoke();
}
#endif
}
}
}
else // get master list from load balancer
@@ -187,6 +210,7 @@ namespace LightReflectiveMirror
using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
{
// webRequest.SetRequestHeader("Proxy-Authorization", "");
webRequest.SetRequestHeader("x-Region", ((int)region).ToString());
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();