public static void ResetPassword(string email, Action <bool> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("email", email); GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/password/reset", JsonMapper.ToJson(body), null, null, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void RestorePassword(string restoreToken, string newPassword, Action <bool> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("password", newPassword); GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/password/restore/" + restoreToken, JsonMapper.ToJson(body), null, sessionToken.session_token, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void LogoutUser(Action <bool> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add(GamedoniaRequest.GD_SESSION_TOKEN, sessionToken.session_token); GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/logout", JsonMapper.ToJson(body), null, sessionToken.session_token, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void ChangePassword(string email, string currentPassword, string newPassword, Action <bool> callback) { string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("email|" + email + "|" + currentPassword)); Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("password", newPassword); GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/password/change", JsonMapper.ToJson(body), auth, null, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void LinkUser(Credentials credentials, Action <bool, GDUserProfile> callback) { GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/link", JsonMapper.ToJson(credentials), null, sessionToken.session_token, null, delegate(bool success, object data) { if (success) { me = DeserializeUserProfile((string)data); } if (callback != null) { callback(success, me); } } ) ); }
public static void Update(string collection, Dictionary <string, object> entity, Action <bool, IDictionary> callback = null, bool overwrite = false) { string json = JsonMapper.ToJson(entity); if (!overwrite) { GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/data/" + collection + "/update", json, null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { if (callback != null) { if (success) { callback(success, Json.Deserialize((string)data) as IDictionary); } else { callback(success, null); } } } ) ); } else { GamedoniaBackend.RunCoroutine( GamedoniaRequest.put("/data/" + collection + "/update", json, null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { if (callback != null) { if (success) { callback(success, Json.Deserialize((string)data) as IDictionary); } else { callback(success, null); } } } ) ); } }
public static void StartMatch(string matchId, Action <bool, GDMatch> callback = null) { GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/matchmaking/start/" + matchId, "{}", null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { GDMatch startedMatch = null; if (success) { startedMatch = DeserializeMatch((string)data); } if (callback != null) { callback(success, startedMatch); } } ) ); }
public static void CreateMatch(GDMatch match, Action <bool, GDMatch> callback = null) { string json = JsonMapper.ToJson(match); GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/matchmaking/create", json, null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { GDMatch createdMatch = null; if (success) { createdMatch = DeserializeMatch((string)data); } if (callback != null) { callback(success, createdMatch); } } ) ); }
public static void GetUser(string userId, Action <bool, GDUserProfile> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("_id", userId); GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/retrieve", JsonMapper.ToJson(body), null, sessionToken.session_token, null, delegate(bool success, object data) { GDUserProfile user = null; if (success) { user = DeserializeUserProfile((string)data); } if (callback != null) { callback(success, user); } } ) ); }
public static void LoginUserWithSessionToken(Action <bool> callback) { string session_token = PlayerPrefs.GetString("gd_session_token"); if (session_token != null && session_token.Length > 0) { string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("session_token|" + session_token)); Dictionary <string, string> body = new Dictionary <string, string> (); body.Add(GamedoniaRequest.GD_AUTH, auth); GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/login", JsonMapper.ToJson(body), auth, null, null, delegate(bool success, object data) { if (success) { sessionToken = JsonMapper.ToObject <GDSessionToken> ((string)data); RegisterDeviceAfterLogin(callback); } else { if (callback != null) { callback(success); } } } ) ); } else { Debug.LogWarning("No sessionToken stored in PlayerPrefs"); if (callback != null) { callback(false); } } }
public static void UpdateUser(Dictionary <string, object> profile, Action <bool> callback = null, bool overwrite = false) { if (!overwrite) { GamedoniaBackend.RunCoroutine( GamedoniaRequest.post("/account/update", JsonMapper.ToJson(profile), null, sessionToken.session_token, null, delegate(bool success, object data) { if (success) { me = DeserializeUserProfile((string)data); } if (callback != null) { callback(success); } } ) ); } else { GamedoniaBackend.RunCoroutine( GamedoniaRequest.put("/account/update", JsonMapper.ToJson(profile), null, sessionToken.session_token, null, delegate(bool success, object data) { if (success) { me = DeserializeUserProfile((string)data); } if (callback != null) { callback(success); } } ) ); } }