From f08e154e6f14d6beabbea2e7f070ed13f2b366db Mon Sep 17 00:00:00 2001 From: Stanislas Dolcini Date: Tue, 9 Oct 2018 13:13:29 +0200 Subject: [PATCH] Add a class to store the server result data --- assets/Scripts/Models/nel_server_info.gd | 16 ++++++++++++++++ gui_scene/GUI/login/login_menu.gd | 10 +++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 assets/Scripts/Models/nel_server_info.gd diff --git a/assets/Scripts/Models/nel_server_info.gd b/assets/Scripts/Models/nel_server_info.gd new file mode 100644 index 0000000..b48e9f9 --- /dev/null +++ b/assets/Scripts/Models/nel_server_info.gd @@ -0,0 +1,16 @@ +class nel_server_info: + var _cookie; + var _shardIp; + var _ringStartAdress; + var _ringAddress; + var _unknowAdress; + var _patchAddress; + + func _init(connexionResultString): + var params = connexionResultString.split('#'); + _cookie = params[1]; + _shardIp = params[2]; + _ringStartAdress = params[3]; + _ringAddress = params[4]; + _unknowAdress = params[5]; + _patchAddress = params[6]; \ No newline at end of file diff --git a/gui_scene/GUI/login/login_menu.gd b/gui_scene/GUI/login/login_menu.gd index 3e4e835..618312e 100644 --- a/gui_scene/GUI/login/login_menu.gd +++ b/gui_scene/GUI/login/login_menu.gd @@ -33,11 +33,15 @@ func do_request(username, password): func _on_HTTPRequest_request_completed(result, response_code, headers, body): var s = body.get_string_from_utf8().split(":") - var ctn = s[0] - # No error so login was successful. - if(ctn != "0"): + if(s[0] != "0"): + var server_info_script = load("res://assets/Scripts/Models/nel_server_info.gd"); + var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8()); + print(server_info._cookie) + print(server_info._shardIp) emit_signal( "login_button_pressed" ) + # No error so login was successful. + func _make_post_request(url, data_to_send, use_ssl): # Convert data to json string: