[ADD] added sending the lobbies data from the server to the clients on startup

This commit is contained in:
Sem van der Hoeven
2020-10-20 21:12:31 +02:00
parent ba1b71d870
commit 671951c35b
6 changed files with 57 additions and 8 deletions

View File

@@ -1,8 +1,10 @@
using Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace SharedClientServer
@@ -79,6 +81,14 @@ namespace SharedClientServer
});
}
public static Lobby[] GetLobbiesFromMessage(byte[] json)
{
dynamic payload = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(json));
JArray lobbiesArray = payload.lobbies;
Debug.WriteLine(lobbiesArray.ToString());
return lobbiesArray.ToObject<Lobby[]>();
}
public static int GetLobbyID(byte[] json)
{
dynamic payload = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(json));