Exemple #1
0
        private static void RetrieveAllModTagsAsync(Action <IDictionary <string, ISet <string> >, bool> onCompletion)
        {
            Action <Exception, string> onGetFail = (e, output) => {
                if (e is JsonReaderException)
                {
                    LogHelpers.Alert("Bad JSON: " + (output.Length > 256 ? output.Substring(0, 256) : output));
                }
                else if (e is WebException || e is NullReferenceException)
                {
                    LogHelpers.Alert((output ?? "...") + " - " + e.Message);
                }
                else
                {
                    LogHelpers.Alert((output ?? "...") + " - " + e.ToString());
                }
            };

            Action <IDictionary <string, ISet <string> >, bool> onGetCompletion = (responseVal, found) => {
                if (responseVal == null)
                {
                    responseVal = new Dictionary <string, ISet <string> >();
                }

                onCompletion(responseVal, found);
            };

            NetHelpers.MakeGetRequestAsync(GetModTags.ModTagsUrl, GetModTags.HandleModTagsReceipt, onGetFail, onGetCompletion);
        }
        private static void RetrieveBadModsAsync(Action <IDictionary <string, int>, bool> onSuccess)
        {
            Action <Exception, string> onFail = (e, output) => {
                if (e is JsonReaderException)
                {
                    LogHelpers.Alert("Bad JSON: " + (output.Length > 256 ? output.Substring(0, 256) : output));
                }
                else if (e is WebException || e is NullReferenceException)
                {
                    LogHelpers.Alert((output ?? "") + " - " + e.Message);
                }
                else
                {
                    LogHelpers.Alert((output ?? "") + " - " + e.ToString());
                }
            };

            Action <IDictionary <string, int>, bool> onCompletion = (responseVal, success) => {
                if (responseVal == null)
                {
                    responseVal = new Dictionary <string, int>();
                }

                onSuccess(responseVal, success);
            };

            NetHelpers.MakeGetRequestAsync(GetModInfo.BadModsUrl, GetModInfo.HandleBadModsReceipt, onFail, onCompletion);
        }
Exemple #3
0
        public void RefreshServerList_Yielding(Action <string, int> pre_join, Action on_success, Action on_err)
        {
            if (this.FullServerList.Count > 0)
            {
                //new Thread( () => { } ).Start();
                lock (UIServerBrowserList.MyLock) {
                    this.FullServerList.Clear();
                    this.MyList.Clear();
                    this.MyList.Recalculate();
                }
            }

            Func <string, Tuple <object, bool> > list_ready = (output) => {
                bool success;

                lock (UIServerBrowserList.MyLock) {
                    this.FullServerList = UIServerBrowserList.GetListFromJsonStr(this.Theme, output, this.Comparator, pre_join, out success);

                    if (this.FullServerList.Count > 0)
                    {
                        this.MyList.AddRange(this.FullServerList);
                        this.Recalculate();
                    }
                }

                if (success)
                {
                    on_success();
                }

                return(Tuple.Create((object)null, success));
            };

            Action <Exception, string> list_error = (e, output) => {
                LogHelpers.Log("List could not load " + e.ToString());
                on_err();
            };

            NetHelpers.MakeGetRequestAsync(
                ServerBrowserReporter.URL,                 //https://script.google.com/macros/s/AKfycbwB2n0X4LWDhpb6wk_VaeWG9gliBi5qLdG7Y8oPgw/exec
                list_ready, list_error
                );
        }