Пример #1
0
        public static void Count(string collection, string query, Action <bool, int> callback = null)
        {
            query = Uri.EscapeDataString(query);
            string url = "/data/" + collection + "/count?query=" + query;

            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(),
                                     delegate(bool success, object data) {
                if (callback != null)
                {
                    if (success)
                    {
                        IDictionary response = Json.Deserialize((string)data) as IDictionary;
                        int count            = int.Parse(response["count"].ToString());
                        callback(success, count);
                    }
                    else
                    {
                        callback(success, -1);
                    }
                }
            }
                                     )
                );
        }
Пример #2
0
        public static void FindMatches(string query, int limit = 0, Action <bool, List <GDMatch> > callback = null)
        {
            string url = "/matchmaking/find?query=" + query;

            if (limit > 0)
            {
                url += "&limit=" + limit;
            }

            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(),
                                     delegate(bool success, object data) {
                if (callback != null)
                {
                    if (success)
                    {
                        if ((data == null) || (data.Equals("[]")))
                        {
                            callback(success, new List <GDMatch>());
                        }
                        else
                        {
                            List <GDMatch> matches = DeserializeMatches((string)data);
                            callback(success, matches);
                        }
                    }
                    else
                    {
                        callback(success, null);
                    }
                }
            }
                                     )
                );
        }
Пример #3
0
 public static void isInternetConnectionAvailable(Action <bool> callback)
 {
     GamedoniaBackend.RunCoroutine(
         GamedoniaRequest.get("/ping", "", delegate(bool success, object data) {
         if (callback != null)
         {
             callback(success);
         }
     })
         );
 }
Пример #4
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);
         }
     }
                              )
         );
 }
Пример #5
0
        public static void Search(string collection, string query, int limit = 0, string sort = null, int skip = 0, Action <bool, IList> callback = null)
        {
            query = Uri.EscapeDataString(query);
            string url = "/data/" + collection + "/search?query=" + query;

            if (limit > 0)
            {
                url += "&limit=" + limit;
            }
            if (sort != null)
            {
                url += "&sort=" + sort;
            }
            if (skip > 0)
            {
                url += "&skip=" + skip;
            }

            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(),
                                     delegate(bool success, object data) {
                if (callback != null)
                {
                    if (success)
                    {
                        if ((data == null) || (data.Equals("[]")))
                        {
                            callback(success, null);
                        }
                        else
                        {
                            callback(success, Json.Deserialize((string)data) as IList);
                        }
                    }
                    else
                    {
                        callback(success, null);
                    }
                }
            }
                                     )
                );
        }
Пример #6
0
        public static void Search(string query, int limit = 0, string sort = null, int skip = 0, Action <bool, IList> callback = null)
        {
            string url = "/account/search?query=" + query;

            if (limit > 0)
            {
                url += "&limit=" + limit;
            }
            if (sort != null)
            {
                url += "&sort=" + sort;
            }
            if (skip > 0)
            {
                url += "&skip=" + skip;
            }

            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.get(url, sessionToken.session_token,
                                     delegate(bool success, object data) {
                if (callback != null)
                {
                    if (success)
                    {
                        if ((data == null) || (data.Equals("[]")))
                        {
                            callback(success, null);
                        }
                        else
                        {
                            callback(success, Json.Deserialize((string)data) as IList);
                        }
                    }
                    else
                    {
                        callback(success, null);
                    }
                }
            }
                                     )
                );
        }
Пример #7
0
 public static void Get(string collection, string entityId, Action <bool, IDictionary> callback = null)
 {
     GamedoniaBackend.RunCoroutine(
         GamedoniaRequest.get("/data/" + collection + "/get/" + entityId, GamedoniaUsers.GetSessionToken(),
                              delegate(bool success, object data) {
         if (callback != null)
         {
             if (success)
             {
                 callback(success, Json.Deserialize((string)data) as IDictionary);
             }
             else
             {
                 callback(success, null);
             }
         }
     }
                              )
         );
 }
Пример #8
0
 public static void GetMatch(string matchId, Action <bool, GDMatch, List <GDMatchEvent> > callback = null)
 {
     GamedoniaBackend.RunCoroutine(
         GamedoniaRequest.get("/matchmaking/get/" + matchId, GamedoniaUsers.GetSessionToken(),
                              delegate(bool success, object data) {
         GDMatch match = null;
         List <GDMatchEvent> events = new List <GDMatchEvent>();
         if (success)
         {
             Dictionary <string, object> result = (Dictionary <string, object>)Json.Deserialize((string)data);
             match  = DeserializeMatch(result["match"] as Dictionary <string, object>);
             events = DeserializeMatchEvents(result["events"] as List <object>);
         }
         if (callback != null)
         {
             callback(success, match, events);
         }
     }
                              )
         );
 }
Пример #9
0
        public static void GetMatches(string state, int limit = 0, string sort = null, int skip = 0, Action <bool, List <GDMatch>, Dictionary <string, List <GDMatchEvent> > > callback = null)
        {
            string queryString = "state=" + state;

            if (limit > 0)
            {
                queryString += "&limit=" + limit;
            }
            if (sort != null)
            {
                queryString += "&sort=" + Uri.EscapeDataString(sort);
            }
            if (skip > 0)
            {
                queryString += "&skip=" + skip;
            }

            string url = "/matchmaking/search?" + queryString;

            Debug.Log(url);
            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(),
                                     delegate(bool success, object data) {
                List <GDMatch> matches = new List <GDMatch>();
                Dictionary <string, List <GDMatchEvent> > events = new Dictionary <string, List <GDMatchEvent> >();
                if (success)
                {
                    Debug.Log("GetMatches worked!");
                    Dictionary <string, object> result = (Dictionary <string, object>)Json.Deserialize((string)data);
                    matches = DeserializeMatches(result["matches"] as List <object>);
                    events  = DeserializeMatchEvents(result["events"] as Dictionary <string, object>);
                }
                if (callback != null)
                {
                    callback(success, matches, events);
                }
            }
                                     )
                );
        }
Пример #10
0
        private void RequestAndAddDownload(string fileId)
        {
            string url = "/file/get/url/" + fileId;


            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(),
                                     delegate(bool success, object data) {
                if (success)
                {
                    //Debug.Log("Before Internal Download URL");
                    IDictionary dataDownload = Json.Deserialize((string)data) as IDictionary;
                    InternalAddDownloadURL(dataDownload["downloadUrl"] as string, fileId);
                }
                else
                {
                    InternalAddDownloadURL(fileId, fileId);
                }
            }
                                     )
                );
        }
Пример #11
0
        public static void Count(string query, Action <bool, int> callback = null)
        {
            string url = "/account/count?query=" + query;

            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.get(url, sessionToken.session_token, delegate(bool success, object data)
            {
                if (callback != null)
                {
                    if (success)
                    {
                        IDictionary response = Json.Deserialize((string)data) as IDictionary;
                        int count            = int.Parse(response["count"].ToString());
                        callback(success, count);
                    }
                    else
                    {
                        callback(success, -1);
                    }
                }
            })
                );
        }