Fixed json returning null
This commit is contained in:
parent
5f3466ad23
commit
6a6ec975e0
1 changed files with 6 additions and 2 deletions
|
|
@ -110,12 +110,16 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string receivedStats = await wc.DownloadStringTaskAsync($"http://{serverIP}:{port}/api/servers");
|
string receivedStats = await wc.DownloadStringTaskAsync($"http://{serverIP}:{port}/api/servers");
|
||||||
return JsonConvert.DeserializeObject<List<Room>>(receivedStats);
|
var stats = JsonConvert.DeserializeObject<List<Room>>(receivedStats);
|
||||||
|
if (stats == null)
|
||||||
|
return new List<Room>();
|
||||||
|
else
|
||||||
|
return stats;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// Server failed to respond
|
// Server failed to respond
|
||||||
return null;
|
return new List<Room>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue