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


C# HTTPRequest类代码示例

本文整理汇总了C#中HTTPRequest的典型用法代码示例。如果您正苦于以下问题:C# HTTPRequest类的具体用法?C# HTTPRequest怎么用?C# HTTPRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onAuthenticationFinished

	void onAuthenticationFinished(HTTPRequest req, HTTPResponse res) {
		JsonReader json = new JsonReader (res.DataAsText);
		json.SkipNonMembers = true;
		// deserialize
		Token token = JsonMapper.ToObject<Token> (json);
		// authentication correct
		if (token != null) {
			if (token.success) {
				// save to player preferences
				PlayerPrefs.SetString ("token", token.token);
				PlayerPrefs.SetString ("username", token.username);
				PlayerPrefs.Save();
				// when we finish the authentication process, load the main menu
				utils.loadScene("MainMenu");
			}
			else {
				Debug.Log(token.message);
				_dispatcher.Dispatch("show_error_register_login");
			}
		}
		// authentication erroneous, show error message
		else {
			//TODO: show error message
		}
	}
开发者ID:mengtest,项目名称:movieschallenge_client,代码行数:25,代码来源:Authenticate.cs

示例2: sendAction

	public void sendAction() {

		GetComponent<Animator>().Play("Click");

		if (buttonType == FLOOR_BUTTON_TYPE.YES || buttonType == FLOOR_BUTTON_TYPE.NO) {

			GameObject.Find("Debug Text").GetComponent<Text>().text += "Setting Position \n";

			HTTPRequest request = new HTTPRequest(new Uri("http://run-west.att.io/d9576f027ee8f/6e9234f387c9/9c7023eee2b3b23/in/flow/action"), HTTPMethods.Put, actionSentCallback);

			JSONClass data = new JSONClass();

			data["value"] = ((int)buttonType).ToString();

			request.AddHeader("Content-Type", "application/json");
			//request.AddHeader("X-M2X-KEY", "9fc7996ea7f03fccc6ef3978f2a4d012");
			request.RawData = Encoding.UTF8.GetBytes(data.ToString());
			request.Send();
		} else {

			HTTPRequest request = new HTTPRequest(new Uri("http://run-west.att.io/d9576f027ee8f/6e9234f387c9/9c7023eee2b3b23/in/flow/dlswitch"), HTTPMethods.Put, actionSentCallback);

			JSONClass data = new JSONClass();

			data["value"] = (dlSwitch).ToString();

			request.AddHeader("Content-Type", "application/json");
			//request.AddHeader("X-M2X-KEY", "9fc7996ea7f03fccc6ef3978f2a4d012");
			request.RawData = Encoding.UTF8.GetBytes(data.ToString());
			request.Send();
		}



	}
开发者ID:ubberkid,项目名称:PeerATT,代码行数:35,代码来源:FloorButton.cs

示例3: Start

 private void Start()
 {
     HTTPRequest request = new HTTPRequest(new Uri(APIUrl.UrlUserId + "/" + PlayerPrefs.GetString("UserId") + "?access_token=" + PlayerPrefs.GetString("token")), HTTPMethods.Get, OnRequestFinished);
     // Debug.Log(APIUrl.UrlUserId + "/" + PlayerPrefs.GetString("UserId") + "?access_token=" + PlayerPrefs.GetString("token"));
     //  request.AddField("id", PlayerPrefs.GetString("UserId"));
     request.Send();
 }
开发者ID:TrangNguyen702,项目名称:DATN_Client,代码行数:7,代码来源:GetUserId.cs

示例4: PrepareRequest

 public override void PrepareRequest(HTTPRequest request)
 {
     if (Form.headers.ContainsKey("Content-Type"))
         request.SetHeader("Content-Type", Form.headers["Content-Type"] as string);
     else
         request.SetHeader("Content-Type", "application/x-www-form-urlencoded");
 }
开发者ID:mengtest,项目名称:movieschallenge_client,代码行数:7,代码来源:UnityForm.cs

示例5: GetImage

    public IEnumerator GetImage(System.Action<Image> callback, System.Action<string> errorCallback)
    {
        if (imageList.Images.Count == 0)
        {
            // no images, get new
            yield return StartCoroutine(GetImages(errorCallback));
        }

        if (imageList.Images.Count == 0)
        {
            yield break;
        }

        int index = Random.Range(0, imageList.Images.Count - 1);
        Image i = imageList.Images[index];

        HTTPRequest req = new HTTPRequest(new System.Uri(i.Url));
        req.Send();
        yield return StartCoroutine(req);

        if(req.Response==null || !req.Response.IsSuccess)
        {
            errorCallback("Get Image Error");
            yield break;
        }

        imageList.Images.RemoveAt(index);

        i.Tex = req.Response.DataAsTexture2D;
        callback(i);
        yield return null;
    }
开发者ID:yueyoum,项目名称:one-client,代码行数:32,代码来源:ImageFactory.cs

示例6: process

        public bool process(Servers.AsynchronousServer.ClientConnection cc, HTTPRequest request)
        {
            if (request.path.StartsWith(PAGE_PREFIX))
            {
                dataRates.addUpLinkPoint(System.DateTime.Now, request.path.Length);

                try
                {
                    dataSources.vessel = FlightGlobals.ActiveVessel;
                    vesselChangeDetector.update(FlightGlobals.ActiveVessel);
                }
                catch (Exception e)
                {
                    PluginLogger.debug(e.Message + " "  + e.StackTrace);
                }

                dataRates.addDownLinkPoint(
                    System.DateTime.Now,
                    ((Servers.MinimalHTTPServer.ClientConnection)cc).Send(new OKResponsePage(
                        argumentsParse(request.path.Remove(0,
                            request.path.IndexOf(ARGUMENTS_START) + 1),
                            dataSources)
                   )));

                return true;
            }

            return false;
        }
开发者ID:Benache,项目名称:Telemachus,代码行数:29,代码来源:DataLinkResponsibility.cs

示例7: SessionInfo

 public  SessionInfo()
 {
     Ignore = false;
     BypassServerRequest = false;
     Response = new HTTPResponse();
     Request = new HTTPRequest();
 }
开发者ID:lscyane,项目名称:KCBr,代码行数:7,代码来源:HTTProxy.cs

示例8: processGameEnd

	void processGameEnd(HTTPRequest req, HTTPResponse res) {
		// deserialize json
		GameModel game = JsonMapper.ToObject<GameModel> (res.DataAsText);
		// update game
		if (!string.IsNullOrEmpty(((GameModel)game)._id)) {
			_dispatcher.Dispatch("update_game", game);
		}
	}
开发者ID:mengtest,项目名称:movieschallenge_client,代码行数:8,代码来源:FinalRoundLogicScript.cs

示例9: HandleRequest

 public void HandleRequest(HTTPRequest request, HTTPResponse response)
 {
     if (_redirectionType == WoopsaRedirectionType.Temporary)
         response.SetStatusCode((int)HTTPStatusCode.TemporaryRedirect, "Temporary redirect");
     else if (_redirectionType == WoopsaRedirectionType.Permanent)
         response.SetStatusCode((int)HTTPStatusCode.Moved, "Permanent redirection");
     response.SetHeader("Location", _targetLocation);
 }
开发者ID:woopsa-protocol,项目名称:Woopsa,代码行数:8,代码来源:RouteHandlerRedirect.cs

示例10: doAuthentication

 void doAuthentication(string username, string password)
 {
     // if there is no token stored, negotiate a new one
     HTTPRequest req = new HTTPRequest (new System.Uri (Properties.API + "/authenticate"), HTTPMethods.Post, onAuthenticationFinished);
     req.AddField ("username", username);
     req.AddField ("password", password);
     req.Send ();
 }
开发者ID:dannisliang,项目名称:movieschallenge_client,代码行数:8,代码来源:Authenticate.cs

示例11: endAPICall

	void endAPICall(HTTPRequest req, HTTPResponse res) {
		// deserialize json
		question = JsonMapper.ToObject<QuestionModel> (res.DataAsText);
		// save questionId
		PlayerPrefs.SetString ("questionId", question._id);
		// end spinning
		callingAPI = false;
	}
开发者ID:mengtest,项目名称:movieschallenge_client,代码行数:8,代码来源:PlayButtonScript.cs

示例12: WebSocketResponse

        internal WebSocketResponse(HTTPRequest request, Stream stream, bool isStreamed, bool isFromCache)
            : base(request, stream, isStreamed, isFromCache)
        {
            base.IsClosedManually = true;

            closed = false;
            MaxFragmentSize = UInt16.MaxValue / 2;
        }
开发者ID:ubberkid,项目名称:PeerATT,代码行数:8,代码来源:WebSocketResponse.cs

示例13: OnAuthRequestFinished

        void OnAuthRequestFinished(HTTPRequest req, HTTPResponse resp)
        {
            AuthRequest = null;
            string failReason = string.Empty;

            switch (req.State)
            {
                // The request finished without any problem.
                case HTTPRequestStates.Finished:
                    if (resp.IsSuccess)
                    {
                        Cookie = resp.Cookies != null ? resp.Cookies.Find(c => c.Name.Equals(".ASPXAUTH")) : null;

                        if (Cookie != null)
                        {
                            HTTPManager.Logger.Information("CookieAuthentication", "Auth. Cookie found!");

                            if (OnAuthenticationSucceded != null)
                                OnAuthenticationSucceded(this);

                            // return now, all other paths are authentication failures
                            return;
                        }
                        else
                            HTTPManager.Logger.Warning("CookieAuthentication", failReason = "Auth. Cookie NOT found!");
                    }
                    else
                        HTTPManager.Logger.Warning("CookieAuthentication", failReason = string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
                                                        resp.StatusCode,
                                                        resp.Message,
                                                        resp.DataAsText));
                    break;

                // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
                case HTTPRequestStates.Error:
                    HTTPManager.Logger.Warning("CookieAuthentication", failReason = "Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
                    break;

                // The request aborted, initiated by the user.
                case HTTPRequestStates.Aborted:
                    HTTPManager.Logger.Warning("CookieAuthentication", failReason = "Request Aborted!");
                    break;

                // Ceonnecting to the server is timed out.
                case HTTPRequestStates.ConnectionTimedOut:
                    HTTPManager.Logger.Error("CookieAuthentication", failReason = "Connection Timed Out!");
                    break;

                // The request didn't finished in the given time.
                case HTTPRequestStates.TimedOut:
                    HTTPManager.Logger.Error("CookieAuthentication", failReason = "Processing the request Timed Out!");
                    break;
            }

            if (OnAuthenticationFailed != null)
                OnAuthenticationFailed(this, failReason);
        }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:57,代码来源:SampleCookieAuthentication.cs

示例14: OnClick

    private void OnClick()
    {
        HTTPRequest request = new HTTPRequest(new Uri(APIUrl.UrlLogin), HTTPMethods.Post, OnRequestFinished);
        request.AddField("username", username.text);
        request.AddField("password", password.text);
        request.Send();

        //SceneManager.LoadScene(1);
    }
开发者ID:TrangNguyen702,项目名称:DATN_Client,代码行数:9,代码来源:LoginButton.cs

示例15: OnRequestFinished

    private void OnRequestFinished(HTTPRequest originalRequest, HTTPResponse response)
    {
        var json = JSON.Parse(response.DataAsText);

        for (int i = 0; i < json.Count; i++)
        {
            itemlist.Add(new Item(
                 json[i]["code"]
                 , json[i]["name"]
                 , json[i]["damage"]
                 , json[i]["price"]
                 , json[i]["avatar"]
                 , json[i]["itemCategoryId"]
                 , json[i]["id"]
                 , json[i]["categoryId"]
                 ));
            //kiem tra xem sung da mua chua
            itemlist [i].bought = 0;
            //Debug.Log ("so sanh item ; " + json [i] ["id"]);
            for(int k = 0; k<GetUserId.itemid.Count; k++){
            //	Debug.Log ("so sanh voi :" + GetUserId.itemid [k]+ "va ;"+ json[i]["id"]);
                if (json [i] ["id"].ToString().Trim('"').Equals( GetUserId.itemid [k].ToString())) {
                    itemlist [i].bought = 1;
                    Debug.Log ("trung nhau giua ;"+ GetUserId.itemid[k] +"va :"+ json[i]["name"]);

                }
            }
            GameObject bullet3;
            if (itemlist [i].bought == 1) {
                 bullet3 = (GameObject)Instantiate (itemprefab2, itemPo [i].transform.position, Quaternion.identity);
            } else {
                 bullet3 = (GameObject)Instantiate (itemprefab1, itemPo [i].transform.position, Quaternion.identity);
            }

            Transform[] allChildren = bullet3.transform.GetComponentsInChildren<Transform>();
            foreach (Transform t in allChildren)
            {
                if (t != null && t.gameObject.name == "Wp")
                {

                    new HTTPRequest(new Uri(json[i]["avatar"]), (request, res)
                    =>
                    {
                        var texture = new Texture2D(0, 0);
                      //  Debug.Log("red.data = "+ res);
                        texture.LoadImage(res.Data);
                      t.GetComponent<SpriteRenderer>().sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                    }
                    ).Send();
                }
            }
            bullet3.transform.SetParent(GameObject.Find("Weapons").transform);
            bullet3.transform.position = itemPo[i].transform.position;
            bullet3.transform.localScale = new Vector3 (0.9f, 0.9f, 0.9f);
        }
    }
开发者ID:TrangNguyen702,项目名称:DATN_Client,代码行数:56,代码来源:GetItems.cs


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