public static List <LeaderboardResult> GetLeaderboard(Server.TokenAndId tai, bool backgammon, bool narde, int size) { string backgammonString = backgammon ? "1" : "0"; string nardeString = narde ? "1" : "0"; string str = "leaderboard " + "id=" + tai.id + ";token=" + tai.token + ";size=" + size + ";" + "backgammon=" + backgammonString + ";narde=" + nardeString; Response response = DBSocketRequest.Send(str); if (response is ErrorResponse) { Exception exception = ((ErrorResponse)response).ThrowException(); throw exception; } else { double[][] result = JsonConvert.DeserializeObject <double[][]>(response.ToString()); List <LeaderboardResult> res = new List <LeaderboardResult>(); for (int i = 0; i < result.Length; i++) { int id = (int)(result[i][0]); int games = (int)(result[i][1]); double roi = (int)(result[i][2]); double rating = (int)(result[i][3]); LeaderboardResult lr = new LeaderboardResult(); lr.id = id; lr.games = games; lr.roi = roi; lr.rating = rating; res.Add(lr); } return(res); } }
void OnApplicationQuit() { DBSocketRequest.Close(); UnityEngine.Debug.Log("Game quit"); StopChat(); if (lw != null) { UnityEngine.Debug.Log("stop toy lobby"); lw.Stop(); } if (gameWidget != null) { UnityEngine.Debug.Log("stop game"); gameWidget.Stop(); } if (!isTest) { LobbyWidget lobby = (LobbyWidget)DataPasser.Get().Get("lobby"); if (lobby != null) { UnityEngine.Debug.Log("stop actual lobby"); lobby.Stop(); } } }
public static void Register(String login, String password) { string str = "register " + "login="******";password=" + password; Response response = DBSocketRequest.Send(str); if (response is ErrorResponse) { Exception exception = ((ErrorResponse)response).ThrowException(); throw exception; } else { RegistractionServerResult result = JsonConvert.DeserializeObject <RegistractionServerResult>(response.ToString()); } }
public static void SetUser(TokenAndId tai, int newRank) { string str = "set_user " + "id=" + tai.id + ";token=" + tai.token + ";new_rank=" + newRank; Response response = DBSocketRequest.Send(str); if (response is ErrorResponse) { Exception exception = ((ErrorResponse)response).ThrowException(); throw exception; } else { return; } }
public static void RequestCoins(Server.TokenAndId tai, int amount) { string str = "add_coins " + "id=" + tai.id + ";token=" + tai.token + ";amount=" + amount; Response response = DBSocketRequest.Send(str); if (response is ErrorResponse) { Exception exception = ((ErrorResponse)response).ThrowException(); throw exception; } else { RegistractionServerResult result = JsonConvert.DeserializeObject <RegistractionServerResult>(response.ToString()); } }
public static User _GetUser(TokenAndId tai, int userId) { string str = "get_user " + "id=" + tai.id + ";token=" + tai.token + ";user_id=" + userId; Response response = DBSocketRequest.Send(str); if (response is ErrorResponse) { Exception exception = ((ErrorResponse)response).ThrowException(); throw exception; } else { UserJsonAvatar result = JsonConvert.DeserializeObject <UserJsonAvatar>(response.ToString()); User user = new User(); result.CopyData(user); user.id = userId; return(user); } }
public static TokenAndId Authorize(String login, String password) { string str = "authorize " + "login="******";password=" + password; Response response = DBSocketRequest.Send(str); if (response is ErrorResponse) { Exception exception = ((ErrorResponse)response).ThrowException(); throw exception; } else { AuthorizationServerResult result = JsonConvert.DeserializeObject <AuthorizationServerResult>(response.ToString()); TokenAndId res = new TokenAndId(); res.token = result.token; res.id = result.id; return(res); } }
public void OnApplicationQuit() { DBSocketRequest.Close(); CloseWidget(); }