当前位置: 首页>>代码示例>>C#>>正文


C# JSONObject.print方法代码示例

本文整理汇总了C#中JSONObject.print方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.print方法的具体用法?C# JSONObject.print怎么用?C# JSONObject.print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSONObject的用法示例。


在下文中一共展示了JSONObject.print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Buy

        /// <summary>
        /// Buys the purchasable virtual item.
        /// Implementation in subclasses will be according to specific type of purchase.
        /// </summary>
        /// <param name="payload">a string you want to be assigned to the purchase. This string
        /// is saved in a static variable and will be given bacl to you when the
        ///  purchase is completed.</param>
        /// <exception cref="Soomla.Store.InsufficientFundsException">throws InsufficientFundsException</exception>
        public override void Buy(string payload)
        {
            SoomlaUtils.LogDebug("SOOMLA PurchaseWithVirtualItem", "Trying to buy a " + AssociatedItem.Name + " with "
                                 + Amount + " pieces of " + TargetItemId);

            VirtualItem item = getTargetVirtualItem ();
            if (item == null) {
                return;
            }

            JSONObject eventJSON = new JSONObject();
            eventJSON.AddField("itemId", AssociatedItem.ItemId);
            StoreEvents.Instance.onItemPurchaseStarted(eventJSON.print(), true);

            if (!checkTargetBalance (item)) {
                StoreEvents.OnNotEnoughTargetItem(StoreInfo.VirtualItems["seed"]);
                return;
            //				throw new InsufficientFundsException (TargetItemId);
            }

            item.Take(Amount);

            AssociatedItem.Give(1);

            // We have to make sure the ItemPurchased event will be fired AFTER the balance/currency-changed events.
            StoreEvents.Instance.RunLater(() => {
                eventJSON = new JSONObject();
                eventJSON.AddField("itemId", AssociatedItem.ItemId);
                eventJSON.AddField("payload", payload);
                StoreEvents.Instance.onItemPurchased(eventJSON.print(), true);
            });
        }
开发者ID:amisiak7,项目名称:jewels2,代码行数:40,代码来源:PurchaseWithVirtualItem.cs

示例2: Buy

        /// <summary>
        /// Buys the purchasable virtual item.
        /// Implementation in subclasses will be according to specific type of purchase.
        /// </summary>
        /// <param name="payload">a string you want to be assigned to the purchase. This string
        /// is saved in a static variable and will be given bacl to you when the
        ///  purchase is completed.</param>
        /// <exception cref="Soomla.Store.InsufficientFundsException">throws InsufficientFundsException</exception>
        public override void Buy(string payload)
        {
            SoomlaUtils.LogDebug(TAG, "Starting in-app purchase for productId: "
                                 + MarketItem.ProductId);

            JSONObject eventJSON = new JSONObject();
            eventJSON.AddField("itemId", AssociatedItem.ItemId);
            StoreEvents.Instance.onItemPurchaseStarted(eventJSON.print(), true);
            SoomlaStore.BuyMarketItem(MarketItem.ProductId, payload);
        }
开发者ID:TagCreativeStudio,项目名称:unity3d-store,代码行数:18,代码来源:PurchaseWithMarket.cs

示例3: PushEventOnGoodBalanceChanged

			public void PushEventOnGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) {
				var eventJSON = new JSONObject();
				eventJSON.AddField("itemId", good.ItemId);
				eventJSON.AddField("balance", balance);
				eventJSON.AddField("amountAdded", amountAdded);

				_pushEventGoodBalanceChanged(eventJSON.print());
			}
开发者ID:Eremes,项目名称:unity3d-store,代码行数:8,代码来源:StoreEvents.cs

示例4: PushEventOnGoodUnequipped

			public void PushEventOnGoodUnequipped(EquippableVG good) {
				var eventJSON = new JSONObject();
				eventJSON.AddField("itemId", good.ItemId);

				_pushEventGoodUnequipped(eventJSON.print());
			}
开发者ID:Eremes,项目名称:unity3d-store,代码行数:6,代码来源:StoreEvents.cs

示例5: Initialize

        public static void Initialize(IStoreAssets storeAssets)
        {
            //			StoreUtils.LogDebug(TAG, "Adding currency");
            JSONObject currencies = new JSONObject(JSONObject.Type.ARRAY);
            foreach(VirtualCurrency vi in storeAssets.GetCurrencies()) {
                currencies.Add(vi.toJSONObject());
            }

            //			StoreUtils.LogDebug(TAG, "Adding packs");
            JSONObject packs = new JSONObject(JSONObject.Type.ARRAY);
            foreach(VirtualCurrencyPack vi in storeAssets.GetCurrencyPacks()) {
                packs.Add(vi.toJSONObject());
            }

            //			StoreUtils.LogDebug(TAG, "Adding goods");
            JSONObject suGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject ltGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject eqGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject upGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject paGoods = new JSONObject(JSONObject.Type.ARRAY);
            foreach(VirtualGood g in storeAssets.GetGoods()){
                if (g is SingleUseVG) {
                    suGoods.Add(g.toJSONObject());
                } else if (g is EquippableVG) {
                    eqGoods.Add(g.toJSONObject());
                } else if (g is UpgradeVG) {
               		            upGoods.Add(g.toJSONObject());
               		        } else if (g is LifetimeVG) {
                    ltGoods.Add(g.toJSONObject());
                } else if (g is SingleUsePackVG) {
                    paGoods.Add(g.toJSONObject());
                }
            }
            JSONObject goods = new JSONObject(JSONObject.Type.OBJECT);
            goods.AddField(JSONConsts.STORE_GOODS_SU, suGoods);
            goods.AddField(JSONConsts.STORE_GOODS_LT, ltGoods);
            goods.AddField(JSONConsts.STORE_GOODS_EQ, eqGoods);
            goods.AddField(JSONConsts.STORE_GOODS_UP, upGoods);
            goods.AddField(JSONConsts.STORE_GOODS_PA, paGoods);

            //			StoreUtils.LogDebug(TAG, "Adding categories");
            JSONObject categories = new JSONObject(JSONObject.Type.ARRAY);
            foreach(VirtualCategory vi in storeAssets.GetCategories()) {
                categories.Add(vi.toJSONObject());
            }

            //			StoreUtils.LogDebug(TAG, "Adding nonConsumables");
            JSONObject nonConsumables = new JSONObject(JSONObject.Type.ARRAY);
            foreach(NonConsumableItem vi in storeAssets.GetNonConsumableItems()) {
                nonConsumables.Add(vi.toJSONObject());
            }

            //			StoreUtils.LogDebug(TAG, "Preparing StoreAssets  JSONObject");
            JSONObject storeAssetsObj = new JSONObject(JSONObject.Type.OBJECT);
            storeAssetsObj.AddField(JSONConsts.STORE_CATEGORIES, categories);
            storeAssetsObj.AddField(JSONConsts.STORE_CURRENCIES, currencies);
            storeAssetsObj.AddField(JSONConsts.STORE_CURRENCYPACKS, packs);
            storeAssetsObj.AddField(JSONConsts.STORE_GOODS, goods);
            storeAssetsObj.AddField(JSONConsts.STORE_NONCONSUMABLES, nonConsumables);

            string storeAssetsJSON = storeAssetsObj.print();

            #if UNITY_ANDROID && !UNITY_EDITOR
            StoreUtils.LogDebug(TAG, "pushing data to StoreAssets on java side");
            using(AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) {
                jniStoreAssets.CallStatic("prepare", storeAssets.GetVersion(), storeAssetsJSON);
            }
            StoreUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on java side)");
            #elif UNITY_IOS && !UNITY_EDITOR
            StoreUtils.LogDebug(TAG, "pushing data to StoreAssets on ios side");
            storeAssets_Init(storeAssets.GetVersion(), storeAssetsJSON);
            StoreUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on ios side)");
            #endif
        }
开发者ID:jennydvr,项目名称:SimpleRunner,代码行数:74,代码来源:StoreInfo.cs

示例6: lmsAppInfo

	IEnumerator lmsAppInfo( string appID, string deviceID, LMSVersionUpdateCallback callback )
	{
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "ApplicationVersion");
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add params
		arr.AddField ("app_id",appID);
		arr.AddField ("device",deviceID);
		// add authkey
		j.AddField ("authKey",MedstarNow_ActivationCode);
		// get the string
		string bodyString = j.print();

		LMSDebug ("LMSIntegration.lmsAppInfo(" + appID + "," + deviceID + ") : bodystring=<" + bodyString + ">");
		
		// Create a download object
		WWW download = new WWW(APPINFO_URL,Encoding.ASCII.GetBytes(bodyString),pingHeaders); 
		yield return download;
		
		string DBResult;
		string DBErrorString;

		if (download.error != null)
		{
			// save the error
			DBResult = "";
			DBErrorString = download.error;
			// decode return
			JSONObject decoder = new JSONObject(download.text);
			JSONObject msg = decoder.GetField ("msg");
			if ( msg != null )
				UnityEngine.Debug.LogError("LMSIntegration.lmsAppInfo() : error=" + download.error + " msg=" + msg.print());
			else
				UnityEngine.Debug.LogError("LMSIntegration.lmsAppInfo() : error=" + download.error);
			// bad return
			if ( callback != null )
				callback(false,"error","error","none",download);
		}
		else
		{
			// decode
			JSONObject decoder = new JSONObject(download.text);
			if ( CheckReturn(decoder) == true )
			{
				JSONObject p = decoder.GetField ("params");
				if ( p != null )
				{
					JSONObject version = p.GetField ("appver");
					JSONObject update = p.GetField ("force_update");
					string msg = "LMSIntegration.lmsAppInfo() : version=" + version.print () + " : update=" + update.print ();
					LMSDebug (msg);
					// ok return
					if ( callback != null )
					{
						callback(true,version.print(true).Replace ("\"",""),update.print(true).Replace ("\"",""),"",download);
					}
				}
			}
			else
			{
				// probably an error, show it
				JSONObject p = decoder.GetField ("params");
				JSONObject msg = p.GetField("msg");
				if ( msg != null )
				{
					UnityEngine.Debug.LogError("LMSIntegration.lmsAppInfo() : msg=" + msg.print ());
					// bad return
					if ( callback != null )
						callback(false,msg.print(),download.text,"none",download);
				}
			}


			DBResult = "ok";

		}
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:81,代码来源:LMSIntegration.cs

示例7: lmsSaveData

	IEnumerator lmsSaveData( string path, string data, LMSSimpleCallback callback )
	{
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "AppData_SaveDump");
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add params
		arr.AddField ("key",path);
		arr.AddField ("data",data);
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);
		// get the string
		string bodyString = j.print();

		LMSDebug ("LMSIntegration.lmsSaveData(" + path + "," + data + ") : bodystring=<" + bodyString + ">");
		
		// Create a download object
		string url = "http://" + URL + "statefull/post";
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString),pingHeaders); 
		yield return download;
		
		string DBResult;
		string DBErrorString;
		
		if (download.error != null)
		{
			// save the error
			DBResult = "";
			DBErrorString = download.error;
			// decode return
			JSONObject decoder = new JSONObject(download.text);
			JSONObject msg = decoder.GetField ("msg");
			UnityEngine.Debug.LogError("LMSIntegration.lmsSaveData() : error, msg=" + msg.print());
			// bad return
			if ( callback != null )
				callback(false,path,"",download);
		}
		else
		{
			// decode
			JSONObject decoder = new JSONObject(download.text);
			if ( CheckReturn(decoder) == true )
			{
				// ok return
				if ( callback != null )
					callback(true,path,"transfer ok",download);
			}
			else
			{
				// probably an error, show it
				JSONObject p = decoder.GetField ("params");
				JSONObject msg = p.GetField("msg");
				if ( msg != null )
				{
					UnityEngine.Debug.LogError("LMSIntegration.lmsSaveData() : msg=" + msg.print ());
					// bad return
					if ( callback != null )
						callback(false,path,msg.print(),download);
				}
			}
					
			DBResult = "ok";
			
		}
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:69,代码来源:LMSIntegration.cs

示例8: equipPriv

		private void equipPriv(EquippableVG good, bool equip, bool notify){
			string itemId = good.ItemId;
			string key = keyGoodEquipped(itemId);
			
			if (equip) {
				PlayerPrefs.SetString(key, "yes");
				if (notify) {
					var eventJSON = new JSONObject();
					eventJSON.AddField("itemId", good.ItemId);
					StoreEvents.Instance.onGoodEquipped(eventJSON.print());
				}
			} else {
				PlayerPrefs.DeleteKey(key);
				if (notify) {
					var eventJSON = new JSONObject();
					eventJSON.AddField("itemId", good.ItemId);
					StoreEvents.Instance.onGoodUnequipped(eventJSON.print());
				}
			}
		}
开发者ID:RodGreen,项目名称:unity3d-store,代码行数:20,代码来源:VirtualGoodsStorage.cs

示例9: lmsGetCoursesUsingContent

	IEnumerator lmsGetCoursesUsingContent( string contentID, LMSCourseInfoCallback callback  )
	{
		//string bodyString = "{\"action\":\"Catalog_ContentAdoptingCourses\",\"params\":{\"content_id\":\"" + contentID + "\"},\"authKey\":" + pingAuthKey + "}";

		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "Catalog_ContentAdoptingCourses");
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add params
		arr.AddField ("content_id",contentID);
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);
		// get bodystring
		string bodyString = j.print();
		
		// Create a download object
		string url = "http://" + URL + "statefull/get";
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString),pingHeaders);
		yield return download;

		LMSDebug ("lmsGetCoursesUsingContent(" + contentID +")");
		LMSDebug ("lmsGetCoursesUsingContent(" + pingAuthKey + ") text=<" + download.text + "> error=<" + download.error + "> bodystring=<" + bodyString + ">");

		string DBResult;
		string DBErrorString;

		// create new list
		LMSCoursesUsingContent = new List<LMSCourseInfo>();
		
		if (download.error != null)
		{
			// save the error
			DBResult = "";
			DBErrorString = download.error;
			if ( callback != null )
				callback(false,"error",contentID,null,download);
		}
		else
		{
			DBResult = "ok";
			// decode
			JSONObject decoder = new JSONObject(download.text);
			if ( CheckReturn(decoder) == true )
			{
				var N = JSONNode.Parse(download.text);
				// extract courses
				if ( N["params"] != null )
				{
					JSONClass tryme = N["params"]["adopting_courses"] as JSONClass;
					if ( tryme != null )
					{
						for( int i=0 ; i<tryme.Count ; i++)
						{
							JSONNode itemNode = N["params"]["adopting_courses"][i];
							if ( itemNode.Count > 0 )
							{
								LMSCoursesUsingContent.Add (new LMSCourseInfo(contentID/*tryme.Key(i)*/,itemNode[0]["course_enrollment_id"].ToString().Replace("\"",""),itemNode[0]["enrollment_date"].ToString().Replace("\"",""),itemNode[0]["course_status"].ToString().Replace("\"","")));
								#if DEBUG_LIST
								UnityEngine.Debug.LogError("key=" + tryme.Key(i) + " item=" + itemNode.ToString () + " count=" + itemNode.Count);
								UnityEngine.Debug.LogError("course_enrollment_id=" + itemNode[0]["course_enrollment_id"].ToString().Replace("\"",""));
								UnityEngine.Debug.LogError("enrollment_date=" + itemNode[0]["enrollment_date"].ToString().Replace("\"",""));
								UnityEngine.Debug.LogError("course_status=" + itemNode[0]["course_status"].ToString().Replace("\"",""));
								UnityEngine.Debug.LogError(">>>>");
								#endif
							}
						}			
					}
					else
						UnityEngine.Debug.LogError ("lmsGetCoursesUsingContent() : tryme==null");
				}
				else
					UnityEngine.Debug.LogError ("lmsGetCoursesUsingContent() : N[params]==null");
				// do callback
				if ( callback != null )
				{
					// if we have courses then send back list otherwise return null
					if ( LMSCoursesUsingContent.Count > 0 )
						callback(true,"enrolled",contentID,LMSCoursesUsingContent,download);
					else
						callback(true,"not_enrolled",contentID,null,download);
				}
			}
			else
			{
				if ( callback != null )
					callback(false,"error",contentID,null,download);
			}
		}
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:93,代码来源:LMSIntegration.cs

示例10: PushEventOnItemPurchaseStarted

			public void PushEventOnItemPurchaseStarted(PurchasableVirtualItem item) {
				var eventJSON = new JSONObject();
				eventJSON.AddField("itemId", item.ItemId);

				_pushEventItemPurchaseStarted(eventJSON.print());
			}
开发者ID:Eremes,项目名称:unity3d-store,代码行数:6,代码来源:StoreEvents.cs

示例11: lmsPing

	IEnumerator lmsPing( string authkey )
	{
		//string bodyString = "{\"action\":\"Ping\",\"params\":null,\"authKey\":" + authkey + "}";
		
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "Ping");
		// make param area
		j.AddField("params", "null");
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);
		// get bodystring
		string bodyString = j.print();
		
		// Create a download object
		string url = "http://" + URL + "statefull/get";
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString),pingHeaders);
		yield return download;

		LMSDebug ("LMSIntegration.lmsPing(" + authkey + ") text=<" + download.text + "> error=<" + download.error + ">");
		DebugPingHeaders();
		
		string DBResult;
		string DBErrorString;
		
		if (download.error != null)
		{
			// save the error
			DBResult = "";
			DBErrorString = download.error;
		}
		else
		{
			DBResult = "ok";
		}
		
		yield return new WaitForSeconds(PingRate);
		
		LMSPing ();
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:42,代码来源:LMSIntegration.cs

示例12: lmsGetUserInfo

	IEnumerator lmsGetUserInfo( UserInfoCallback callback )
	{
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "User_Info");
		// make param area
		j.AddField("params", "null");
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);
		// get bodystring
		string bodyString = j.print();

		LMSDebug("lmsGetUserInfo: bodyString=[" + bodyString +"]");
		
		// Create a download object
		string url = "http://" + URL + "statefull/get";
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString),pingHeaders);
		yield return download;
		
		if (download.error != null)
		{
			LMSDebug("lmsGetUserInfo: download.error=" + download.error);

			// save the error
			if ( callback != null )
				callback(false,download.error);
			UserInfo.Valid = false;
		}
		else
		{
			// decode
			// "{"action":"response","params":{"fname":"Itay","lname":"Moav","email":"[email protected]","current_org":"eonflux"},"authKey":"c1nsqupar527qcjhc0s5m93le5","dbgenv":"192.168.12.148"}"			
			JSONObject decoder = new JSONObject(download.text);
			if ( CheckReturn(decoder) == true )
			{
				var N = JSONNode.Parse(download.text);
				UserInfo.FirstName = N["params"]["fname"].ToString(); 
				UserInfo.LastName = N["params"]["lname"].ToString(); 
				UserInfo.Email = N["params"]["email"].ToString();
				UserInfo.Org = N["params"]["current_org"].ToString();
				UserInfo.Valid = true;
				LMSDebug("lmsGetUserInfo: UserInfo.Valid=" + LMSIntegration.UserInfo.Valid);
				if ( callback != null )
					callback(true,download.text);
			}
			else
			{
				LMSDebug("lmsGetUserInfo: download.text=" + download.text);
				if ( callback != null )
					callback(false,download.text);
			}
		}
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:55,代码来源:LMSIntegration.cs

示例13: lmsLoginWithPing

	IEnumerator lmsLoginWithPing( string username, string password, DatabaseMgr.Callback Callback )
	{
		//string URL="http://192.168.12.148/api3/corwin/r2d0/statefull/auth/";
		//string bodyString = "{\"action\":\"NoOrg\",\"params\":{\"username\":\"" + username + "\",\"password\":\"" + password + "\"},\"authKey\":null}";
		
		string url = "http://" + URL + "statefull/auth";
		//string bodyString = "{\"action\":\"User\",\"params\":{\"user_name\":\"" + username + "\",\"password\":\"" + password + "\"},\"authKey\":null}";
		
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "NoOrg");
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add params
		arr.AddField ("username",username);
		arr.AddField ("password", password );
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);

		// get bodystring
		string bodyString = j.print();
		
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString));

		yield return download;
		
		//Application.ExternalCall("Debug","LMSIntegration.lmsLoginWithPing() : URL=" + url + " : bodyString=" + bodyString + " : text=" + download.text + " : error=" + download.error );
	
		string DBResult="";
		string DBErrorString;
		
		if (download.error != null)
		{
			LMSDebug ("LMSIntegration.lmsLoginWithPing(" + username + "," + password + ") url=<" + url + "> bodyString=<" + bodyString + "> error=<" + download.error + ">"); 
			// save the error
			DBResult = null;
			DBErrorString = download.error;
			// do callback
			if (Callback != null)
				Callback(false, DBResult, DBErrorString, download);
			// do global callback
			if (DatabaseMgr.GetInstance() != null && DatabaseMgr.GetInstance().ErrorCallback != null )
				DatabaseMgr.GetInstance().ErrorCallback(false,DBResult,DBErrorString,download);
		}
		else
		{
			LMSDebug ("LMSIntegration.lmsLoginWithPing(" + username + "," + password + ") url=<" + url + "> bodyString=<" + bodyString + "> text=<" + download.text + ">");			
			if ( download.text == null )
			{
				DBResult = "invalid";
				UnityEngine.Debug.LogError ("LMSIntegration.LMSLoginWithPing() : download.text is null!");
			}
			else
			{
				JSONObject decoder = new JSONObject(download.text);
				if ( CheckReturn(decoder) == true )
				{
					JSONObject authkey = decoder.GetField ("authKey");
					if ( authkey != null )
					{
#if !UNITY_WEBPLAYER
						// get response headers
						GetCookies(download);
#endif
						// get authkey
						pingAuthKey = authkey.print ();
						LMSPing (pingAuthKey);
						DBResult = "ok";
					}
					else
					{
						DBResult = "invalid";
						UnityEngine.Debug.LogError ("LMSIntegration.LMSLoginWithPing() : username=<" + username + "> password=<" + password + "> result=" + download.text);
					}
				}
				else
				{
					DBResult = "invalid";
					UnityEngine.Debug.LogError ("LMSIntegration.LMSLoginWithPing() : username=<" + username + "> password=<" + password + "> result=" + download.text);
				}
			}
			// save the results
			DBErrorString = "";
			// do callback
			if (Callback != null)
				Callback(true, DBResult, DBErrorString, download);
		}
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:91,代码来源:LMSIntegration.cs

示例14: lmsLogin

	IEnumerator lmsLogin( string username, string password, DatabaseMgr.Callback Callback )
	{
		string url = "http://www.sitelms.org/restapi/auth";
		//string bodyString = "{\"action\":\"User\",\"params\":{\"user_name\":\"" + username + "\",\"password\":\"" + password + "\"},\"authKey\":null}";
		
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "User");
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add params
		arr.AddField ("user_name",username);
		arr.AddField ("password", password );
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);
		// get bodystring
		string bodyString = j.print();
		
		// Create a download object
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString));
		yield return download;
		
		//Application.ExternalCall("Debug","LMSIntegration.lmsLogin() : URL=" + url + " : bodyString=" + bodyString );
		
		string DBResult;
		string DBErrorString;
		
		if (download.error != null)
		{
			DBResult = "";
			DBErrorString = download.error;
			// do callback
			if (Callback != null)
				Callback(false, DBResult, DBErrorString, download);
			// do global callback
			if (DatabaseMgr.GetInstance().ErrorCallback != null )
				DatabaseMgr.GetInstance().ErrorCallback(false,DBResult,DBErrorString,download);
		}
		else
		{
			if ( download.text == null )
			{
				DBResult = "invalid";
				UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : download.text is null!");
			}
			else
			{
				JSONObject decoder = new JSONObject(download.text);
				if ( CheckReturn(decoder) == true )
				{
					JSONObject authkey = decoder.GetField ("authKey");
					if ( authkey != null )
					{
						if ( authkey.print () != "null" )
						{
							DBResult = "ok";
							UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : authKey=" + authkey.print () + " : valid");
						}
						else
						{
							DBResult = "invalid";
							UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : authKey=" + authkey.print () + " : not valid");
						}
					}
					else
					{
						DBResult = "invalid";
						UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : username=<" + username + "> password=<" + password + "> result=" + download.text);
					}
				}
				else
				{
					DBResult = "invalid";
					UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : username=<" + username + "> password=<" + password + "> result=" + download.text);
				}
			}
			// save the results
			DBErrorString = "";
			// do callback
			if (Callback != null)
				Callback(true, DBResult, DBErrorString, download);
		}
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:86,代码来源:LMSIntegration.cs

示例15: LMSSendXApiList

	public void LMSSendXApiList( List<XApiLogItem> list )
	{
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add all elements to params array
		foreach( XApiLogItem item in list )
		{
			arr.Add(item.ToJSON());
		}
		string result = j.print();
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:14,代码来源:LMSIntegration.cs


注:本文中的JSONObject.print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。