void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (this.callback != null)
     {
         callback(success);
     }
 }
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (_callback != null)
     {
         _callback(true);
     }
 }
Example #3
0
        private static List <GDMatch> DeserializeMatches(List <object> matches)
        {
            List <GDMatch> matchesList = new List <GDMatch> ();

            foreach (object matchObj in matches)
            {
                Dictionary <string, object> matchMap = matchObj as Dictionary <string, object>;
                GDMatch match = new GDMatch();
                match._id        = matchMap ["_id"] as string;
                match.state      = matchMap ["state"] as string;
                match.properties = matchMap ["properties"] as Dictionary <string, object>;
                List <object> usersList = matchMap ["users"] as List <object>;


                foreach (object userObj in usersList)
                {
                    Dictionary <string, object> userMap = userObj as Dictionary <string, object>;
                    GDUserProfile user = new GDUserProfile();
                    user._id     = userMap["_id"] as string;
                    user.profile = userMap["profile"] as Dictionary <string, object>;
                    match.users.Add(user);
                }

                matchesList.Add(match);
            }
            return(matchesList);
        }
        private static GDUserProfile DeserializeUserProfile(string data)
        {
            //Debug.Log ("Deserializing user");
            IDictionary   userMap = Json.Deserialize((string)data) as IDictionary;
            GDUserProfile user    = new GDUserProfile();

            user._id     = userMap["_id"] as string;
            user.profile = userMap["profile"] as Dictionary <string, object>;

            return(user);
        }
 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 GetMe(Action <bool, GDUserProfile> callback)
 {
     GamedoniaBackend.RunCoroutine(
         GamedoniaRequest.get("/account/me", sessionToken.session_token,
                              delegate(bool success, object data) {
         //if (success) me = JsonMapper.ToObject<GDUserProfile>((string)data);
         if (success)
         {
             me = DeserializeUserProfile((string)data);
         }
         if (callback != null)
         {
             callback(success, me);
         }
     }
                              )
         );
 }
        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 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);
             }
         }
                                  )
             );
     }
 }
Example #9
0
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (this.callback != null) callback(success);
 }
Example #10
0
        private static GDUserProfile DeserializeUserProfile(string data)
        {
            //Debug.Log ("Deserializing user");
            IDictionary userMap = Json.Deserialize((string)data) as IDictionary;
            GDUserProfile user = new GDUserProfile ();

            user._id = userMap["_id"] as string;
            user.profile = userMap["profile"] as Dictionary<string,object>;

            return user;
        }
Example #11
0
 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);
                 }
          	 )
         );
     }
 }
Example #12
0
 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);
             }
         )
     );
 }
Example #13
0
 public static void GetMe(Action<bool, GDUserProfile> callback)
 {
     GamedoniaBackend.RunCoroutine(
         GamedoniaRequest.get("/account/me",sessionToken.session_token,
             delegate (bool success, object data) {
                 //if (success) me = JsonMapper.ToObject<GDUserProfile>((string)data);
                 if (success) me = DeserializeUserProfile((string)data);
                 if (callback != null) callback(success, me);
             }
      	 )
     );
 }
Example #14
0
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (_callback != null) _callback(true);
 }
Example #15
0
        private static List<GDMatch> DeserializeMatches(List<object> matches)
        {
            List<GDMatch> matchesList = new List<GDMatch> ();

            foreach (object matchObj in matches) {
                Dictionary<string,object> matchMap = matchObj as Dictionary<string,object>;
                GDMatch match = new GDMatch ();
                match._id = matchMap ["_id"] as string;
                match.state = matchMap ["state"] as string;
                match.properties = matchMap ["properties"] as Dictionary<string,object>;
                List<object> usersList = matchMap ["users"] as List<object>;

                foreach(object userObj in usersList) {
                    Dictionary<string,object> userMap = userObj as Dictionary<string,object>;
                    GDUserProfile user = new GDUserProfile();
                    user._id = userMap["_id"] as string;
                    user.profile = userMap["profile"] as Dictionary<string,object>;
                    match.users.Add(user);
                }

                matchesList.Add(match);
            }
            return matchesList;
        }