/// <summary>
        /// Create a new request data container based on a json string.
        /// </summary>
        /// <param name="jsonString"></param>
        public GSRequestData(string jsonString)
        {
            object o = GSJson.From(jsonString);

            if (o is IDictionary <string, object> )
            {
                this._data = ((IDictionary <string, object>)o);
            }
        }
        /// <summary>
        /// Parse the given json string into a new GSObject.
        /// </summary>
        public static GSObject FromJson(String json)
        {
            object parsed = GSJson.From(json);

            if (parsed is IDictionary <string, object> )
            {
                return(new GSObject((IDictionary <string, object>)parsed));
            }
            return(null);
        }
        public void Upload(GSObject getUploadUrlResponse)
        {
            GameSparksFormUpload.FileParameter param = new GameSparksFormUpload.FileParameter(file);
            param.FileName = fileName;
            IDictionary <string, object> postParams = new Dictionary <string, object>();

            postParams.Add("file", param);
            if (getUploadUrlResponse.ContainsKey("url"))
            {
                String response = GameSparksFormUpload.MultipartFormDataPost(getUploadUrlResponse.GetString("url"), "GameSparksUploadAPI", postParams);
                getUploadUrlResponse.Add("uploadResponse", GSJson.From(response));
            }
        }
Beispiel #4
0
 private void GSConnection_OnMessageReceived(String message)
 {
     try{
         if (_gSPlatform.ApiSecret.Contains(":"))
         {
             message = Decrypt(message);
             if (SessionId != null)
             {
                 IDictionary <string, object> parsed = (IDictionary <string, object>)GSJson.From(message);
                 GSData secureResponse = new GSData(parsed);
                 string json           = secureResponse.GetString("json");
                 if (secureResponse.GetString("hmac").Equals(_gs.GSPlatform.MakeHmac(json, GS.GSPlatform.ApiSecret + "-" + SessionId)))
                 {
                     _gs.AddRequestedAction(() => {
                         _gs.OnMessageReceived(json, this);
                     });
                 }
                 else
                 {
                     if (_gs.TraceMessages)
                     {
                         _gSPlatform.DebugMsg("SOCKET-TAMPERED:" + secureResponse.JSON);
                     }
                 }
                 return;
             }
         }
         _gs.AddRequestedAction(() => {
             _gs.OnMessageReceived(message, this);
         });
     }catch {
         //on WP8 if the app goes out of score for some reason the gs is null, so ignore this
     }
 }
 /// <summary>
 /// Add a json string which will be converted into an object first.
 /// </summary>
 public GSRequestData AddJSONStringAsObject(string paramName, string jsonString)
 {
     Add(paramName, GSJson.From(jsonString));
     return(this);
 }