コード例 #1
0
        /// <summary>Requests a file over the internet.</summary>
        /// <param name="url">The url to request.</param>
        /// <param name="onDone">A method to call with the result.</param>
        /// <param name="extraData">An object which will be available in the onDone method.</param>
        public static void Request(string url, OnHttpEvent onDone, object extraData)
        {
            HttpRequest request = new HttpRequest(url, onDone);

            request.ExtraData = extraData;
            request.Send();
        }
コード例 #2
0
        /// <summary>Requests a file over the internet and posts form data to it.</summary>
        /// <param name="url">The url to request.</param>
        /// <param name="onDone">A method to call with the result.</param>
        /// <param name="form">A http form to send with the request.</param>
        public static void Request(string url, OnHttpEvent onDone, WWWForm form)
        {
            HttpRequest request = new HttpRequest(url, onDone);

            if (form != null)
            {
                request.AttachForm(form);
            }

            request.Send();
        }
コード例 #3
0
		/// <summary>Performs a post request, sending the given post data.</summary>
		/// <param name="url">The URL to request.</param>
		/// <param name="postData">The data to send (as a UTF8 string).</param>
		/// <param name="callback">The callback to run when the request completes.</param>
		/// <param name="extraData">A custom object to pass to the callback when the request completes.</param>
		public static void Post(string url,string postData,DynamicMethod<Nitro.Void> callback,object extraData){
			HttpRequest request=new HttpRequest(url,OnAjaxDone);
			request.ExtraData=new object[]{callback,extraData};
			request.PostData=System.Text.Encoding.UTF8.GetBytes(postData);
			request.Send();
		}
コード例 #4
0
//--------------------------------------
コード例 #5
0
		/// <summary>Performs a simple get request, calling the callback with the result.</summary>
		/// <param name="url">The URL to request.</param>
		/// <param name="callback">The callback to run when the request completes.</param>
		/// <param name="extraData">A custom object to pass to the callback when the request completes.</param>
		public static void Get(string url,DynamicMethod<Nitro.Void> callback,object extraData){
			HttpRequest request=new HttpRequest(url,OnAjaxDone);
			request.ExtraData=new object[]{callback,extraData};
			request.Send();
		}
コード例 #6
0
		/// <summary>Requests a file over the internet.</summary>
		/// <param name="url">The url to request.</param>
		/// <param name="onDone">A method to call with the result.</param>
		/// <param name="extraData">An object which will be available in the onDone method.</param>
		public static void Request(string url,OnHttpEvent onDone,object extraData){
			HttpRequest request=new HttpRequest(url,onDone);
			request.ExtraData=extraData;
			request.Send();
		}
コード例 #7
0
		/// <summary>Requests a file over the internet and posts form data to it.</summary>
		/// <param name="url">The url to request.</param>
		/// <param name="onDone">A method to call with the result.</param>
		/// <param name="form">A http form to send with the request.</param>
		public static void Request(string url,OnHttpEvent onDone,WWWForm form){
			HttpRequest request=new HttpRequest(url,onDone);
			
			if(form!=null){
				request.AttachForm(form);
			}
			
			request.Send();
		}
コード例 #8
0
//--------------------------------------
コード例 #9
0
		public override void OnGetText(TextPackage package,FilePath path){
			// Work like a proper browser - Let's go grab text from the given url.
			// Note that this will only work with simple sites (no JS - nitro only) or ones built specifically for PowerUI.
			HttpRequest request=new HttpRequest(path.Url,GotTextResult);
			request.ExtraData=package;
			request.Send();
		}
コード例 #10
0
		public override void OnGetGraphic(ImagePackage package,FilePath path){
			// Work like a proper browser - let's go get the image from the web.
			// Second is for video - it's called when the video is ready for playback but
			// Not necessarily fully downloaded.
			
			// First, was this graphic already requested?
			// If so, we'll provide that immediately.
			ImagePackage previousRequest=GetFromCache(path.Url);
			
			if(previousRequest!=null){
				// Great - provide this packages result first.
				// This prevents any flashing if innerHTML is loaded.
				package.GotCached(previousRequest);
				return;
			}
			
			HttpRequest request=new HttpRequest(path.Url,GotGraphicResult);
			request.OnRequestReady+=GotGraphicResult;
			request.ExtraData=package;
			request.Send();
		}
コード例 #11
0
		public override void OnGetData(DataPackage package,FilePath path){
			HttpRequest request=new HttpRequest(path.Url,GotDataResult);
			request.ExtraData=package;
			request.Send();
		}
コード例 #12
0
		public override void OnPostForm(FormData form,Element formElement,FilePath path){
			// Post to HTTP; Action is our URL.
			HttpRequest request=new HttpRequest(path.Url,OnFormSent);
			request.ExtraData=formElement;
			request.AttachForm(form.ToUnityForm());
			request.Send();
		}