Beispiel #1
0
        private IEnumerator checkout(Action<CheckoutResponse> callback)
        {
            Request r = new Request("game/checkout");

            WWW w = runRequest(r);
            yield return w; // wait for response

            CheckoutResponse res = new CheckoutResponse(processWWWResult(w));
            if (!res.Ready)
            {
                res.ErrorId = ErrorId;
                res.ErrorText = ErrorText;
            }
            else CurrentCheckin = null;

            callback(res);
        }
Beispiel #2
0
        private IEnumerator score(int value, Action<ScoreResponse> callback)
        {
            Request r = new Request("game/score");
            r.AddString("score", value.ToString());

            WWW w = runRequest(r);
            yield return w; // wait for response

            ScoreResponse res = new ScoreResponse(processWWWResult(w));
            if (!res.Ready)
            {
                res.ErrorId = ErrorId;
                res.ErrorText = ErrorText;
            }
            else CurrentCheckin = null;

            callback(res);
        }
Beispiel #3
0
        private WWW runRequest(Request data)
        {
            Loading = true;
            string path = data.Path;

            WWWForm form = new WWWForm();
            form.AddField("json", data.ToJSONString()); //TODO: encryption
            if (Connected) form.AddField("s", SessionId);

            return new WWW(ApiURL + Path.Combine(ApiURL, path), form);
        }
Beispiel #4
0
        private IEnumerator logout(Action<User> callback)
        {
            Request r = new Request("logout");

            WWW w = runRequest(r);
            yield return w; // wait for response

            if (w.error == null)
            {
                JSONNode n = decode(w.text);

                user.Validated = !n["success"].AsBool;
                if (!user.Validated) SessionId = "";
            }
            else Debug.LogError("Server error");

            Loading = false;
            callback(user);
        }
Beispiel #5
0
        private IEnumerator login(Action<User> callback)
        {
            Request r = new Request("login");
            r.AddString("name", user.Name);
            r.AddString("device", user.DeviceId);

            WWW w = runRequest(r);
            yield return w; // wait for response

            processWWWResult(w, true);
            callback(user);
        }
Beispiel #6
0
        private IEnumerator register(Action<User> callback)
        {
            Request r = new Request("register");
            r.AddString("code", user.GroupCode);
            r.AddString("name", user.Name);
            r.AddString("char", user.Character);
            r.AddString("email", user.Email);
            r.AddString("password", user.Password);
            r.AddString("device", user.DeviceId);

            WWW w = runRequest(r);
            yield return w; // wait for response

            processWWWResult(w, true); // autologin after register
            callback(user);
        }
Beispiel #7
0
        private IEnumerator checkin(string markerKey, string markerValue, Action<CheckinResponse> callback)
        {
            Request r = new Request("game/checkin");
            r.AddString("marker", markerKey);
            r.AddString("value", markerValue);

            WWW w = runRequest(r);
            yield return w; // wait for response

            CheckinResponse res = new CheckinResponse(processWWWResult(w));
            if (!res.Ready)
            {
                res.ErrorId = ErrorId;
                res.ErrorText = ErrorText;
            }
            else CurrentCheckin = res;

            callback(res);
        }