Esempio n. 1
0
        private static IEnumerator <UnityWebRequestAsyncOperation> GenerateGrammarCoroutine(Grammar grammar, Action <GenerateGrammarResponse> resolve, Action <Exception> reject)
        {
            IsLoading     = true;
            IsUnreachable = false;
            var form = new WWWForm();

            form.AddField("ID", grammar.id);
            form.AddField("Name", grammar.name);
            form.AddField("Type", grammar.type);
            form.AddField("Code", grammar.SourceCode ? grammar.SourceCode.text : grammar.code);
            form.AddField("OnlyNID", uint.MaxValue.ToString());
            form.AddField("Render", "false");

            using (var postRequest = UnityWebRequest.Post(URLConstants.GrammarAPI, form).WithCookies(CookiesString)) {
                yield return(postRequest.SendWebRequest());

                if (CheckAndLogError(postRequest))
                {
                    reject(GenerateException("Generate grammar request error:\n", postRequest));
                    yield break;
                }

                var response = MessagePackSerializer.Deserialize <PostResponseModel>(postRequest.downloadHandler.data);
                MichelangeloSingleton.Coroutine(GetResponseCoroutine(grammar.id, response.IMG, resolve, reject));
            }
        }
Esempio n. 2
0
        private static IEnumerator <UnityWebRequestAsyncOperation> GenerateSceneCoroutine(string code, Action <GenerateGrammarResponse> resolve, Action <Exception> reject)
        {
            IsLoading     = true;
            IsUnreachable = false;
            var form = new WWWForm();

            form.AddField("Type", "DOG");
            form.AddField("Code", code);

            using (var postRequest = UnityWebRequest.Post(URLConstants.SceneAPI, form).WithCookies(CookiesString)) {
                yield return(postRequest.SendWebRequest());

                if (CheckAndLogError(postRequest))
                {
                    reject(GenerateException("Generate scene request error:\n", postRequest));
                    yield break;
                }

                var response = MessagePackSerializer.Deserialize <PostResponseModel>(postRequest.downloadHandler.data);
                MichelangeloSingleton.Coroutine(GetResponseCoroutine(response.Info, response.IMG, resolve, reject));
            }
        }
Esempio n. 3
0
 internal static IPromise Logout() => new Promise((resolve, reject) => MichelangeloSingleton.Coroutine(LogoutCoroutine(Wrap(resolve), Wrap(reject))));
Esempio n. 4
0
 internal static IPromise Login(string email, string password) => new Promise((resolve, reject) => MichelangeloSingleton.Coroutine(LoginCoroutine(email, password, Wrap(resolve), Wrap(reject))));
Esempio n. 5
0
 internal static IPromise <GenerateGrammarResponse> GenerateScene(string code) => new Promise <GenerateGrammarResponse>((resolve, reject) => MichelangeloSingleton.Coroutine(GenerateSceneCoroutine(code, Wrap(resolve), Wrap(reject))));
Esempio n. 6
0
 internal static IPromise <GenerateGrammarResponse> GenerateGrammar(Grammar grammar) => new Promise <GenerateGrammarResponse>((resolve, reject) => MichelangeloSingleton.Coroutine(GenerateGrammarCoroutine(grammar, Wrap(resolve), Wrap(reject))));
Esempio n. 7
0
 internal static IPromise DeleteGrammar(string grammarId) => new Promise((resolve, reject) => MichelangeloSingleton.Coroutine(DeleteGrammarCoroutine(grammarId, Wrap(resolve), Wrap(reject))));
Esempio n. 8
0
 internal static IPromise <Grammar> GetTutorial(string grammarId) => new Promise <Grammar>((resolve, reject) => MichelangeloSingleton.Coroutine(GetGrammarCoroutine(URLConstants.TutorialAPI, grammarId, Wrap(resolve), Wrap(reject))));
Esempio n. 9
0
 internal static IPromise <Grammar> CreateGrammar() => new Promise <Grammar>((resolve, reject) => MichelangeloSingleton.Coroutine(CreateGrammarCoroutine(Wrap(resolve), Wrap(reject))));
Esempio n. 10
0
 internal static IPromise <Grammar[]> GetTutorialGrammarArray() => new Promise <Grammar[]>((resolve, reject) => MichelangeloSingleton.Coroutine(GetGrammarArrayCoroutine(URLConstants.TutorialAPI, Wrap(resolve), Wrap(reject))));
Esempio n. 11
0
 internal static IPromise <UserInfo> GetUserInfo() => new Promise <UserInfo>((resolve, reject) => MichelangeloSingleton.Coroutine(GetUserInfoCoroutine(Wrap(resolve), Wrap(reject))));