Use correct OOP

This commit is contained in:
Stanislas Dolcini 2018-10-04 17:14:22 +02:00
parent 394a603d6f
commit 9a853aad42
2 changed files with 34 additions and 3 deletions

View file

@ -0,0 +1,32 @@
class nel_login_message:
var _cmd;
var _login;
var _password;
var _clientApplication;
var _cp;
var _lg;
func _init(cmd, login, password, clientApplication, cp, lg):
self._cmd = cmd;
self._login = login;
self._password = password;
self._clientApplication = clientApplication;
self._cp = cp;
self._lg = lg;
func get_request_string():
var request_string = "cmd=" + self._cmd;
if self._login != "":
request_string += "&login=" + self._login;
if self._password != "":
request_string += "&password=" + self._password;
if self._clientApplication != "":
request_string += "&clientApplication=" + self._clientApplication
if self._cp != "":
request_string += "&cp=" + self._cp
if self._lg != "":
request_string += "&lg=" + self._lg
return request_string;

View file

@ -25,9 +25,8 @@ func _on_sound_button_toggled( button_pressed ):
func do_request(username):
var headers = ["Content-Type: application/json"]
#$HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?cmd=ask&login=" + username)
$HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?cmd=ask", headers, true, HTTPClient.METHOD_GET, "&login=" + username)
var message = load("res://assets/Scripts/Models/nel_login_message.gd").nel_login_message.new("ask", username, "", "", "", "");
$HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string());
func _on_HTTPRequest_request_completed(result, response_code, headers, body):