Exemple #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);
            };
        }
Exemple #2
0
        public Task create(WebPack pack, Handler succeed, Handler error)
        {
            WWW  www  = pack.www() as WWW;
            Task task = new Task();
            bool over = false;

            task.init = delegate {
                over = false;
                StartCoroutine(WebTaskFactory.GetInstance().linkIt(www, succeed, error, delegate {
                    over = true;
                }));
            };

            task.isOver = delegate {
                return(over);
            };
            return(task);
        }