OnlineDatabase.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Mono.Data.Sqlite;
  5. using System.Data;
  6. using System;
  7. using UnityEngine.Networking;
  8. using System.IO;
  9. public class OnlineDatabase : MonoBehaviour {
  10. private const string onlineQuestionsUrl = "nordh.xyz/narKampen/dbFiles/Question.php";
  11. private const string serverUrl = "nordh.xyz/narKampen/dbFiles/";
  12. string databaseUrl;
  13. string gameMode;
  14. int winAmount = -1;
  15. int questionTimer = -1;
  16. public GameObject questionCardPrefab;
  17. private static OnlineDatabase instance;
  18. public static OnlineDatabase Instance { get { return instance; } }
  19. private void Awake() {
  20. if (instance == null) {
  21. instance = this;
  22. }
  23. }
  24. internal List<CategoryPanel.Category> GetCategories(List<CategoryPanel.Category> list) {
  25. string response = CallOnlineDatabaseWithResponse("Categories.php", null);
  26. response = "{\"categoryList\" : " + response + " }";
  27. Categories categories = new Categories();
  28. JsonUtility.FromJsonOverwrite(response, categories);
  29. foreach (Category c in categories.categoryList) {
  30. CategoryPanel.Category cat = new CategoryPanel.Category();
  31. cat.color = new Color32((byte)c.r, (byte)c.g, (byte)c.b, (byte)c.a);
  32. cat.name = c.name;
  33. cat.id = c.id;
  34. list.Add(cat);
  35. }
  36. return list;
  37. }
  38. internal void SetupNewOnlineGame(int limitPerQuestion, int limitPerPlayer, int toWin, List<InviteSearchResult> inviteUsers) {
  39. List<int> playerIds = new List<int>();
  40. inviteUsers.ForEach(i => playerIds.Add(i.GetId()));
  41. int currentUser = Database.Instance.GetSignedInUser().Key;
  42. playerIds.Add(currentUser);
  43. var form = new WWWForm();
  44. form.AddField("currentUser", currentUser);
  45. form.AddField("winNumber", toWin);
  46. form.AddField("limitPerQuestion", limitPerQuestion);
  47. form.AddField("limitPerPlayer", limitPerPlayer);
  48. form.AddField("playerIds", String.Join(",", playerIds));
  49. Debug.Log(CallOnlineDatabaseWithResponse("NewOnlineGame.php", form));
  50. }
  51. [Serializable]
  52. public class Question {
  53. public string question;
  54. public string answer;
  55. public string id;
  56. public string category;
  57. }
  58. [Serializable]
  59. public class Questions {
  60. public List<Question> questionsList = new List<Question>();
  61. }
  62. [Serializable]
  63. public class PlayerInfo {
  64. public string username;
  65. public string status;
  66. }
  67. [Serializable]
  68. public class PlayerInfos {
  69. public List<PlayerInfo> playerInfoList = new List<PlayerInfo>();
  70. }
  71. [Serializable]
  72. public class GamePlayerInfo {
  73. public string username;
  74. public string userLockedQuestions;
  75. }
  76. [Serializable]
  77. public class GamePlayerInfos {
  78. public List<GamePlayerInfo> gamePlayerInfoList = new List<GamePlayerInfo>();
  79. }
  80. [Serializable]
  81. public class Category {
  82. public int r;
  83. public int g;
  84. public int b;
  85. public int a;
  86. public int id;
  87. public string name;
  88. }
  89. [Serializable]
  90. public class Categories {
  91. public List<Category> categoryList = new List<Category>();
  92. }
  93. [Serializable]
  94. public class OnlineGame {
  95. public string id;
  96. public string winNumber;
  97. public string answerTimer;
  98. public string roundTimeLimit;
  99. public string currentPlayer;
  100. public string round;
  101. public string startDate;
  102. public string LastPlayedDate;
  103. public string finishedDate;
  104. public string status;
  105. }
  106. [Serializable]
  107. public class OnlineGames {
  108. public List<OnlineGame> onlineGamesList = new List<OnlineGame>();
  109. }
  110. [Serializable]
  111. public class UserName {
  112. public string id;
  113. public string username;
  114. }
  115. [Serializable]
  116. public class UserNames {
  117. public List<UserName> usernamesList = new List<UserName>();
  118. }
  119. private void CallDatabase(string filename, WWWForm formData) {
  120. string postUrl = serverUrl + filename;
  121. UnityWebRequest www = UnityWebRequest.Post(postUrl, formData);
  122. www.SendWebRequest();
  123. if (www.isNetworkError || www.isHttpError) {
  124. Debug.Log(www.error);
  125. } else {
  126. while (!www.isDone) {
  127. }
  128. }
  129. }
  130. private string CallOnlineDatabaseWithResponse(string filename, WWWForm formData) {
  131. string postUrl = serverUrl + filename;
  132. UnityWebRequest www = UnityWebRequest.Post(postUrl, formData);
  133. www.SendWebRequest();
  134. if (www.isNetworkError || www.isHttpError) {
  135. Debug.Log(www.error);
  136. } else {
  137. while (!www.isDone) {
  138. }
  139. }
  140. return www.downloadHandler.text;
  141. }
  142. string questionString = "";
  143. string answerString = "";
  144. string idString = "";
  145. string categoryString = "";
  146. private int round = -1;
  147. private string SearchString;
  148. public string QuestionString { get => questionString; set => questionString = value; }
  149. private void Start() {
  150. if (instance == null) {
  151. instance = this;
  152. }
  153. }
  154. internal void SetLastPlayedDate(int gameId) {
  155. WWWForm form = new WWWForm();
  156. form.AddField("gameId", gameId);
  157. form.AddField("f", "SetLastPlayed");
  158. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  159. if (!response.Equals("")) {
  160. Debug.Log(response);
  161. }
  162. }
  163. internal void DeclineOnlineGame(string userName, int gameId) {
  164. WWWForm formData = new WWWForm();
  165. formData.AddField("userId", -1);
  166. formData.AddField("f", "decline");
  167. formData.AddField("gameId", gameId);
  168. formData.AddField("userName", userName);
  169. CallDatabase("OnlineGames.php", formData);
  170. }
  171. internal void AcceptOnlineGame(string userName, int gameId) {
  172. WWWForm formData = new WWWForm();
  173. formData.AddField("userId", -1);
  174. formData.AddField("f", "accept");
  175. formData.AddField("gameId", gameId);
  176. formData.AddField("userName", userName);
  177. CallDatabase("OnlineGames.php", formData);
  178. }
  179. internal List<OnlineGameScript> GetOnlineGames(int userId, string userName, GameObject prefab) {
  180. WWWForm formData = new WWWForm();
  181. formData.AddField("userId", userId);
  182. formData.AddField("f", "list");
  183. formData.AddField("gameId", -1);
  184. formData.AddField("userName", userName);
  185. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", formData);
  186. if (response.Equals("No games found for user")) {
  187. return null;
  188. }
  189. response = "{\"onlineGamesList\" : " + response + " }";
  190. OnlineGames og = new OnlineGames();
  191. JsonUtility.FromJsonOverwrite(response, og);
  192. GameObject onlineGameObject;
  193. OnlineGameScript ogs = null;
  194. List<OnlineGameScript> games = new List<OnlineGameScript>();
  195. foreach (OnlineGame game in og.onlineGamesList) {
  196. onlineGameObject = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
  197. ogs = onlineGameObject.GetComponent<OnlineGameScript>();
  198. ogs.CurrentPlayer = game.currentPlayer;
  199. ogs.SetGameStatus(game.status);
  200. Int32.TryParse(game.id, out int gameId);
  201. List<KeyValuePair<string, string>> playerInfos = GetGameInfo(gameId);
  202. if (game.status.Equals("PENDING")) {
  203. string extraInfo = "";
  204. foreach (KeyValuePair<string, string> s in playerInfos) {
  205. if (s.Value.Equals("WAITING") && s.Key.Equals(userName)) {
  206. ogs.SetGameStatus("INVITED");
  207. extraInfo += s.Key + ",";
  208. } else if (s.Value.EndsWith("WAITING")) {
  209. extraInfo += s.Key + ",";
  210. }
  211. }
  212. extraInfo = extraInfo.TrimEnd(',');
  213. ogs.SetGameStatusText(extraInfo);
  214. } else if (game.status.Equals("OTHERS_TURN")) { // Wont work
  215. ogs.SetGameStatusText(game.currentPlayer);
  216. } else if (game.status.Equals("ACTIVE")) {
  217. ogs.SetGameStatusText(game.currentPlayer);
  218. } else {
  219. ogs.SetGameStatusText();
  220. }
  221. ogs.SetId(game.id);
  222. ogs.SetWinNumber(game.winNumber);
  223. ogs.SetAnswerTimer(game.answerTimer);
  224. ogs.SetRoundTimeLimit(game.roundTimeLimit);
  225. ogs.SetRound(game.round);
  226. ogs.StartDate = game.startDate;
  227. games.Add(ogs);
  228. ogs.PlayerInfos = playerInfos;
  229. }
  230. return games;
  231. }
  232. internal List<KeyValuePair<string, string>> GetGameInfo(int gameId) {
  233. List<KeyValuePair<string, string>> returnList = new List<KeyValuePair<string, string>>();
  234. WWWForm form = new WWWForm();
  235. form.AddField("gameId", gameId);
  236. string response = CallOnlineDatabaseWithResponse("OnlineGameInfo.php", form);
  237. response = "{\"playerInfoList\" : " + response + " }";
  238. PlayerInfos pi = new PlayerInfos();
  239. JsonUtility.FromJsonOverwrite(response, pi);
  240. foreach (PlayerInfo p in pi.playerInfoList) {
  241. KeyValuePair<string, string> player = new KeyValuePair<string, string>(p.username, p.status);
  242. returnList.Add(player);
  243. }
  244. return returnList;
  245. }
  246. internal void SetQuestionsLost(int gameId, string playerName, int questionsLost) {
  247. WWWForm form = new WWWForm();
  248. form.AddField("f", "SetQuestionsLost");
  249. form.AddField("questionsLost", questionsLost);
  250. form.AddField("userName", playerName);
  251. form.AddField("gameId", gameId);
  252. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  253. if (!response.Equals("")) {
  254. Debug.Log(response);
  255. }
  256. }
  257. internal void RemoveGame(int gameId) {
  258. WWWForm form = new WWWForm();
  259. form.AddField("f", "DeleteGame");
  260. form.AddField("gameId", gameId);
  261. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  262. if (!response.Equals("")) {
  263. Debug.Log(response);
  264. }
  265. }
  266. public string GetCurrentPlayer(int gameId) {
  267. WWWForm form = new WWWForm();
  268. form.AddField("f", "CurrentPlayer");
  269. form.AddField("gameId", gameId);
  270. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  271. if (response.Equals("")) {
  272. Debug.Log("Something wrong with current player for game with id: " + gameId);
  273. }
  274. return response;
  275. }
  276. public void SetCurrentPlayer(int gameId, string currentPlayer) {
  277. WWWForm form = new WWWForm();
  278. form.AddField("f", "SetCurrentPlayer");
  279. form.AddField("gameId", gameId);
  280. form.AddField("currentPlayer", currentPlayer);
  281. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  282. if (!response.Equals("")) {
  283. Debug.Log(response);
  284. }
  285. }
  286. internal int GetPlayerPoints(int gameId, string playerName) {
  287. WWWForm form = new WWWForm();
  288. form.AddField("f", "GetPlayerPoints");
  289. form.AddField("gameId", gameId);
  290. form.AddField("userName", playerName);
  291. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  292. if (response.Equals("")) {
  293. Debug.Log("Something wrong with current player for game with id: " + gameId);
  294. }
  295. Int32.TryParse(response, out int playerPoints);
  296. return playerPoints;
  297. }
  298. internal void SetFinishedDate(int gameId, string finishedDate) {
  299. WWWForm form = new WWWForm();
  300. form.AddField("f", "SetFinishedDate");
  301. form.AddField("gameId", gameId);
  302. form.AddField("finishedDate", finishedDate);
  303. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  304. if (!response.Equals("")) {
  305. Debug.Log(response);
  306. }
  307. }
  308. internal void SetRoundValue(int gameId, int round) {
  309. WWWForm form = new WWWForm();
  310. form.AddField("f", "SetRound");
  311. form.AddField("gameId", gameId);
  312. form.AddField("round", round);
  313. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  314. if (!response.Equals("")) {
  315. Debug.Log(response);
  316. }
  317. }
  318. internal int GetRoundValue(int gameId) {
  319. WWWForm form = new WWWForm();
  320. form.AddField("f", "GetRound");
  321. form.AddField("gameId", gameId);
  322. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  323. if (response.Equals("")) {
  324. Debug.Log("Something wrong with getting round for game with id: " + gameId);
  325. }
  326. Int32.TryParse(response, out int round);
  327. return round;
  328. }
  329. internal List<KeyValuePair<string, int>> GetPlayersForGame(int gameId) {
  330. WWWForm form = new WWWForm();
  331. form.AddField("f", "GetPlayers");
  332. form.AddField("gameId", gameId);
  333. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  334. if (response.Equals("")) {
  335. Debug.Log("Something wrong with getting players from game with id: " + gameId);
  336. }
  337. response = response = "{\"playerInfoList\" : " + response + " }";
  338. GamePlayerInfos gpi = new GamePlayerInfos();
  339. JsonUtility.FromJsonOverwrite(response, gpi);
  340. List<KeyValuePair<string, int>> returnList = new List<KeyValuePair<string, int>>();
  341. foreach (GamePlayerInfo p in gpi.gamePlayerInfoList) {
  342. Int32.TryParse(p.userLockedQuestions, out int points);
  343. KeyValuePair<string, int> player = new KeyValuePair<string, int>(p.username, points);
  344. returnList.Add(player);
  345. }
  346. return returnList;
  347. }
  348. public string AnswerString { get => answerString; set => answerString = value; }
  349. public string IdString { get => idString; set => idString = value; }
  350. public string CategoryString { get => categoryString; set => categoryString = value; }
  351. internal int GetQuestionsLost(int gameId, string playerName) {
  352. WWWForm form = new WWWForm();
  353. form.AddField("f", "GetQuestionsLost");
  354. form.AddField("userName", playerName);
  355. form.AddField("gameId", gameId);
  356. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  357. if (response.Equals("")) {
  358. Debug.Log("Something wrong with getting questions lost from game with id: " + gameId + " and playername " + playerName);
  359. }
  360. Int32.TryParse(response, out int questionsLost);
  361. return questionsLost;
  362. }
  363. public string GetGameMode(int gameId) {
  364. if (this.gameMode == null) {
  365. string sql = "SELECT gameMode FROM game WHERE id = " + gameId;
  366. IDbConnection conn = new SqliteConnection(databaseUrl);
  367. conn.Open();
  368. IDbCommand cmd = conn.CreateCommand();
  369. cmd.CommandText = sql;
  370. IDataReader reader = cmd.ExecuteReader();
  371. while (reader.Read()) {
  372. this.gameMode = reader.GetString(0);
  373. }
  374. reader.Close();
  375. cmd.Dispose();
  376. conn.Close();
  377. }
  378. return this.gameMode;
  379. }
  380. public void LinkPlayersToLocalGame(List<string> playerNames, int gameId) {
  381. IDbConnection conn = new SqliteConnection(databaseUrl);
  382. conn.Open();
  383. string questionSql = "SELECT id FROM questions order by random() limit 1";
  384. IDbCommand cmd = conn.CreateCommand();
  385. cmd.CommandText = questionSql;
  386. IDataReader reader = cmd.ExecuteReader();
  387. int questionId = -1;
  388. while (reader.Read()) {
  389. questionId = reader.GetInt32(0);
  390. }
  391. foreach (string player in playerNames) {
  392. string sql = "SELECT id FROM localUsers WHERE name = '" + player + "'";
  393. int playerId;
  394. cmd = conn.CreateCommand();
  395. cmd.CommandText = sql;
  396. reader = cmd.ExecuteReader();
  397. if (reader.Read()) {
  398. playerId = reader.GetInt32(0);
  399. } else {
  400. reader.Close();
  401. sql = "INSERT INTO localUsers (name) VALUES ('" + player + "')";
  402. cmd.CommandText = sql;
  403. cmd.ExecuteNonQuery();
  404. cmd.CommandText = "SELECT last_insert_rowid()";
  405. Int64 lastInsert64 = (Int64)cmd.ExecuteScalar();
  406. playerId = (int)lastInsert64;
  407. }
  408. cmd.Dispose();
  409. reader.Close();
  410. LinkPlayerToGame(playerId, gameId);
  411. SavePlayersQuestion(questionId.ToString(), player, gameId);
  412. }
  413. IDbCommand cmd2 = conn.CreateCommand();
  414. cmd2.CommandText = "UPDATE game SET currentPlayer = '" + playerNames[0] + "' WHERE id = " + gameId;
  415. cmd2.ExecuteNonQuery();
  416. cmd2.Dispose();
  417. conn.Close();
  418. }
  419. private void LinkPlayerToGame(int playerId, int gameId) {
  420. string sql = "INSERT INTO localGamePlayers (gameId, playerId) VALUES (" + gameId + ", " + playerId + ")";
  421. SqliteConnection conn2 = new SqliteConnection(databaseUrl);
  422. conn2.Open();
  423. IDbCommand cmd = conn2.CreateCommand();
  424. cmd.CommandText = sql;
  425. cmd.ExecuteNonQuery();
  426. cmd.Dispose();
  427. conn2.Close();
  428. }
  429. internal int GetWinCondition(int gameId) {
  430. if (winAmount == -1) {
  431. string sql = "SELECT winNumber FROM game WHERE id = " + gameId;
  432. IDbConnection conn = new SqliteConnection(databaseUrl);
  433. conn.Open();
  434. IDbCommand cmd = conn.CreateCommand();
  435. cmd.CommandText = sql;
  436. IDataReader reader = cmd.ExecuteReader();
  437. while (reader.Read()) {
  438. this.winAmount = reader.GetInt32(0);
  439. }
  440. reader.Close();
  441. cmd.Dispose();
  442. conn.Close();
  443. }
  444. return this.winAmount;
  445. }
  446. public NewQuestion GetNewQuestion(List<int> userAnsweredQuestions, string userName) {
  447. int gameId = GameObject.Find("GameManager").GetComponent<GameManagerScript>().GameId;
  448. Color32 questionCategoryColor = new Color32(0, 0, 20, 20);
  449. GetQuestionData(false);
  450. NewQuestion q = NewQuestion.Instance();
  451. q.questionString = questionString;
  452. q.answerString = answerString;
  453. q.categoryString = categoryString;
  454. q.idString = idString;
  455. q.SetQuestionCategoryColor(questionCategoryColor);
  456. return q;
  457. }
  458. public void SavePlayersQuestion(string questionId, string playerNameValue, int gameId) {
  459. string gameMode = PlayerPrefs.GetString("GameMode");
  460. Int32.TryParse(questionId, out int qId);
  461. if (gameMode.Equals("Local")) {
  462. string sql = "INSERT OR IGNORE INTO usersLockedQuestions (playerName, questionId, gameId) VALUES ('" + playerNameValue + "'," + qId + "," + gameId + ")";
  463. IDbConnection conn = new SqliteConnection(databaseUrl);
  464. conn.Open();
  465. IDbCommand cmd = conn.CreateCommand();
  466. cmd.CommandText = sql;
  467. cmd.ExecuteReader();
  468. cmd.Dispose();
  469. conn.Close();
  470. } else {
  471. // TODO Save question to database online;
  472. }
  473. }
  474. public List<QuestionCard> GetPlayerQuestions(int gameId, string playerNameValue) {
  475. List<QuestionCard> questions = new List<QuestionCard>();
  476. /*
  477. if (connectionType.Equals("Local")) {
  478. string sql = "SELECT * FROM questions inner join questionToCategory on questions.id = questionToCategory.questionId INNER JOIN category ON category.id = questionToCategory.categoryId WHERE questions.id IN ( SELECT questionId FROM usersLockedQuestions WHERE gameId = " + gameId + " AND playerName = '" + playerNameValue + "') ORDER BY answer ASC";
  479. IDbConnection conn = new SqliteConnection(databaseUrl);
  480. conn.Open();
  481. IDbCommand cmd = conn.CreateCommand();
  482. cmd.CommandText = sql;
  483. IDataReader reader = cmd.ExecuteReader();
  484. while (reader.Read()) {
  485. GameObject question = Instantiate(questionCardPrefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
  486. QuestionCard q = question.GetComponent<QuestionCard>();
  487. q.SetAnswerText(reader.GetInt32(2).ToString());
  488. q.SetQuestionText(reader.GetString(1));
  489. q.idString = reader.GetInt32(0).ToString();
  490. Color32 questionCategoryColor = new Color32((byte)reader.GetInt32(7), (byte)reader.GetInt32(8), (byte)reader.GetInt32(9), (byte)reader.GetInt32(10));
  491. q.SetQuestionCategoryColor(questionCategoryColor);
  492. questions.Add(q);
  493. }
  494. cmd.Dispose();
  495. conn.Close();
  496. }
  497. */
  498. // TODO Fix online call to question
  499. return questions;
  500. }
  501. private void GetQuestionData(bool showAnswer) {
  502. WWWForm form = new WWWForm();
  503. string response = CallOnlineDatabaseWithResponse("Question.php", form);
  504. // Show result
  505. response = "{\"questionsList\" : [ " + response + " ]}";
  506. Questions qe = new Questions();
  507. JsonUtility.FromJsonOverwrite(response, qe);
  508. questionString = qe.questionsList[0].question;
  509. answerString = qe.questionsList[0].answer;
  510. idString = qe.questionsList[0].id;
  511. categoryString = qe.questionsList[0].category;
  512. }
  513. public List<UserName> GetUsersToInvite(string searchString) {
  514. string postUrl = "nordh.xyz/narKampen/dbFiles/PlayerSearch.php?";
  515. postUrl += "search=" + UnityWebRequest.EscapeURL(searchString);
  516. UserNames uNames = new UserNames();
  517. UnityWebRequest www = UnityWebRequest.Get(postUrl);
  518. www.SendWebRequest();
  519. if (www.isNetworkError || www.isHttpError) {
  520. Debug.Log(www.error);
  521. } else {
  522. while (!www.isDone) {
  523. }
  524. // Show result
  525. string jsonData = www.downloadHandler.text;
  526. jsonData = "{\"usernamesList\" : " + jsonData + " }";
  527. JsonUtility.FromJsonOverwrite(jsonData, uNames);
  528. }
  529. // TODO handle empty
  530. return uNames.usernamesList;
  531. }
  532. }