コード例 #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
ファイル: GamedoniaUsers.cs プロジェクト: Derojo/Medical
 void HandleGetMe(bool success, GDUserProfile profile)
 {
     if (this.callback != null) callback(success);
 }
コード例 #10
0
ファイル: GamedoniaUsers.cs プロジェクト: Derojo/Medical
        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
ファイル: GamedoniaUsers.cs プロジェクト: Derojo/Medical
 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
ファイル: GamedoniaUsers.cs プロジェクト: Derojo/Medical
 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
ファイル: GamedoniaUsers.cs プロジェクト: Derojo/Medical
 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
ファイル: GamedoniaUsers.cs プロジェクト: Derojo/Medical
 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;
        }