コード例 #1
0
        protected static void SendRequest(string point, JsonObject args, System.Action <JsonObject> success, System.Action <string> failed)
        {
            var argsBytes = System.Text.Encoding.UTF8.GetBytes(GoWMiniJSON.Serialize(args));
            var request   = WebRequest.Create(Settings.serverUrl + "/" + point);

            request.Method        = "POST";
            request.ContentType   = "application/json";
            request.ContentLength = argsBytes.Length;
            var dataStream = request.GetRequestStream();

            dataStream.Write(argsBytes, 0, argsBytes.Length);
            dataStream.Close();
            try {
                var response = request.GetResponse();

                webErrorLine = null;

                if (success != null)
                {
                    success((JsonObject)GoWMiniJSON.Deserialize(GetTextResponse(response)));
                }
            } catch (WebException e) {
                var errorResponse = (JsonObject)GoWMiniJSON.Deserialize(GetTextResponse(e.Response));
                webErrorLine = errorResponse["error"].ToString();
                if (failed != null)
                {
                    failed(webErrorLine);
                }
                LogUtils.LogError(webErrorLine);
            }
        }
コード例 #2
0
ファイル: DeviceInfoIos.cs プロジェクト: zendorx/testapp
        private void OnCurrentPushMessage(string response)
        {
            var jsonResponse = GowMiniJSON.Deserialize(response) as JsonObject;
            var notification = jsonResponse.Get <JsonObject>("currentPushMessage");

            OnCurrentNotificationRecieved(notification);
        }
コード例 #3
0
        private void DefaultDialogCallback(string response)
        {
            var jsonResponse         = GOWMiniJSON.Deserialize(response) as JsonObject;
            var dialogResponseString = jsonResponse.Get <string>("response");

            if (string.IsNullOrEmpty(dialogResponseString))
            {
                LogUtils.LogError("Incorrect dialog response: " + dialogResponseString);
            }
            try
            {
                var dialogResponse = (DialogButtons)Enum.Parse(typeof(DialogButtons), dialogResponseString);
                if (_currentDialogRequest != null)
                {
                    var callback = dialogResponse == DialogButtons.Ok
                        ? _currentDialogRequest.onOk
                        : _currentDialogRequest.onCancel;
                    if (callback != null)
                    {
                        callback();
                    }
                }
            }
            catch (ArgumentException e)
            {
                Debug.LogError("Parse enum exception: " + e.Message + "\r\n" + e.StackTrace);
            }
            _currentDialogRequest = null;
        }
コード例 #4
0
        protected static JsonObject DecodeToken(string token)
        {
            var parts   = token.Split('.');
            var header  = parts[0];
            var payload = parts[1];

            byte[] crypto = Base64UrlDecode(parts[2]);

            var headerJson  = System.Text.Encoding.UTF8.GetString(Base64UrlDecode(header));
            var headerData  = (JsonObject)GoWMiniJSON.Deserialize(headerJson);
            var payloadJson = System.Text.Encoding.UTF8.GetString(Base64UrlDecode(payload));
            var payloadData = (JsonObject)GoWMiniJSON.Deserialize(payloadJson);

            return(payloadData);
        }
コード例 #5
0
ファイル: DeviceInfoIos.cs プロジェクト: zendorx/testapp
        private void OnPushMessages(string response)
        {
            var jsonResponse  = GowMiniJSON.Deserialize(response) as JsonObject;
            var objectsList   = jsonResponse.Get <List <object> >("notifications");
            var notifications = new List <JsonObject>();

            objectsList.ForEach(o =>
            {
                var item = o as JsonObject;
                if (item != null)
                {
                    notifications.Add(item);
                }
            });
            OnNotificationsRecieved(notifications.ToArray());
        }
コード例 #6
0
        public GowDataStorage()
        {
            var line = PlayerPrefs.GetString(GOW_DATA, null);

            if (string.IsNullOrEmpty(line))
            {
                _gowData = new JsonObject();
            }
            else
            {
                try
                {
                    _gowData = (JsonObject)GoWMiniJSON.Deserialize(line);
                }
                catch (Exception e)
                {
                    LogUtils.LogError(e.Message);
                    LogUtils.LogError(e.StackTrace);
                    _gowData = new JsonObject();
                }
            }
        }