예제 #1
0
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (this.callback != null)
     {
         callback(success);
     }
 }
예제 #2
0
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (_callback != null)
     {
         _callback(true);
     }
 }
예제 #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);
        }
예제 #4
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);
        }
예제 #5
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);
         }
     }
                               )
         );
 }
예제 #6
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);
         }
     }
                              )
         );
 }
예제 #7
0
        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);
                }
            }
                                      )
                );
        }
예제 #8
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);
             }
         }
                                  )
             );
     }
 }
예제 #9
0
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (this.callback != null) callback(success);
 }
예제 #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;
        }
예제 #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);
                 }
          	 )
         );
     }
 }
예제 #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);
             }
         )
     );
 }
예제 #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);
             }
      	 )
     );
 }
예제 #14
0
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (_callback != null) _callback(true);
 }
예제 #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;
        }