public override void _Ready() { base._Ready(); httpRequest = new HTTPRequest(); AddChild(httpRequest); httpRequest.Connect("request_completed", this, nameof(OnRequestCompleted)); }
private void GetAccessToken(string code) { Dictionary <string, string> parameters = new Dictionary <string, string> { { "client_id", _clientId }, { "client_secret", _clientSecret }, { "grant_type", "authorization_code" }, { "redirect_uri", "http://localhost:8910/callback/" }, { "code", code }, { "scope", _scope } }; _request.Connect("request_completed", this, nameof(GetAccessTokenRequestCompleted)); _request.Request($"{_apiEndpoint}/oauth2/token", new[] { "Content-Type: application/x-www-form-urlencoded" }, true, HTTPClient.Method.Post, string.Join("&", parameters.Select(kvp => $"{WebUtility.UrlEncode(kvp.Key)}={WebUtility.UrlEncode(kvp.Value)}"))); }
private void StartAutoRequest() { Console.WriteLine("In auto connection mode, making request..."); var req = new HTTPRequest(); GetTree().Root.AddChild(req); req.Connect("request_completed", this, nameof(AutoRequestCompleted)); req.Request(AutoRequestURI); }
public override void _Ready() { RequestEn = GetNode <HTTPRequest>("HTTPRequestEn"); RequestEn.Connect("request_completed", this, nameof(Enviar)); RequestRe = GetNode <HTTPRequest>("HTTPRequestRe"); RequestRe.Connect("request_completed", this, nameof(Receber)); AddChild(con); AddChild(texto2); AddChild(ed); AddChild(ed2); AddChild(ed3); AddChild(ed4); AddChild(btn1); AddChild(btn2); AddChild(ed5); AddChild(ed6); AddChild(ed7); AddChild(ed8); AddChild(btn3); AddChild(btn4); //Texto texto2.SetPosition(new Vector2(350, 205)); //Painel con.SetPosition(new Vector2(250, 200)); con.SetSize(new Vector2(350, 200)); btn1.Connect("pressed", this, nameof(Logar)); btn4.Connect("pressed", this, nameof(Informe), new Godot.Collections.Array() { "Login" }); btn2.Connect("pressed", this, nameof(Pressionar), new Godot.Collections.Array() { "Cadastro" }); btn3.Connect("pressed", this, nameof(Pressionar), new Godot.Collections.Array() { "Login" }); }
void SendRequest(string requestData = "") { if (_url.StartsWith("file://")) { string path = _url.Substring(7); Debug.Log(_url); if (System.IO.File.Exists(path)) { _bytes = System.IO.File.ReadAllBytes(path); } else { error = "Couldn't find file at path: " + path; } _isDone = true; } else { requestNode = new HTTPRequest() { UseThreads = true }; UnityEngineAutoLoad.Instance.AddChild(requestNode); requestNode.Connect("request_completed", this, "_on_request_completed"); string[] headers = new string[] { "Content-Type: application/x-www-form-urlencoded", "Content-Length: " + requestData.Length }; requestNode.Request(_url, headers, false, (int)_method, requestData); } }