Beispiel #1
0
        public WebLoaderTask(string url)
        {
            pack_ = new WebPack(url);
            pack_.addField("a", "b");
            bool isOver = false;

            this.init = delegate {
                isOver   = false;
                Task web = WebTaskFactory.GetInstance().create(pack, delegate(string json) {
                    if (onSucceed != null)
                    {
                        T info = JsonDataHandler.reader <T>(json);
                        if (WebTimestamp.GetInstance() != null)
                        {
                            WebTimestamp.GetInstance().synchro(info.epoch);
                        }
                        onSucceed(info);
                    }
                }, delegate(string msg) {
                    if (onError != null)
                    {
                        onError(msg);
                    }
                });
                TaskManager.PushBack(web, delegate {
                    isOver = true;
                });
                this.isOver = delegate {
                    return(isOver);
                };
                TaskManager.Run(web);
            };
        }
Beispiel #2
0
        private void succeed(string json)
        {
            Debug.Log(json);
            T t = JsonUtility.FromJson <T> (json);

            if (t.succeed)
            {
                WebTimestamp.GetInstance().synchro(t.epoch);
                if (onSucceed != null)
                {
                    onSucceed(t);
                }
            }
            else
            {
                error(t.message);
            }
        }