test-client-godot/assets/Scripts/Network/net_low_level.gd

61 lines
2.1 KiB
GDScript3
Raw Normal View History

# Class to manage low level communication with khaganat
#
# Copyright (C) 2019 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
extends Control
2020-01-24 18:56:51 +00:00
var _networkconnection = NetworkConnection.new()
2020-03-30 20:20:59 +00:00
var _referentialmessage = ReferentialMessage.new()
2020-01-19 19:13:57 +00:00
func _ready():
2020-04-18 22:36:11 +00:00
pass
2020-03-03 21:45:30 +00:00
#func send_system_login(host, port, user_addr, user_key, user_id, lang):
# _networkconnection.define_server(host, port)
# _networkconnection.define_user(user_addr, user_key, user_id)
# _networkconnection.define_lang(lang)
# _networkconnection.connect_to_server()
2019-12-11 21:27:49 +00:00
func send_system_quit():
2020-04-18 22:36:11 +00:00
_networkconnection.send_system_quit()
2019-12-11 21:27:49 +00:00
func send_systemm_disconnect():
2020-04-18 22:36:11 +00:00
_networkconnection.send_systemm_disconnect()
func disconnect_server():
2020-04-18 22:36:11 +00:00
_networkconnection.disconnect_server()
2020-01-19 19:13:57 +00:00
func connect_to_server(host, port, user_addr, user_key, user_id, lang):
2020-04-18 22:36:11 +00:00
_networkconnection.define_server(host, port)
_networkconnection.define_user(user_addr, user_key, user_id)
_networkconnection.define_lang(lang)
_networkconnection.connect_to_server()
#send_system_login(host, port, user_addr, user_key, user_id, lang)
2019-12-11 21:27:49 +00:00
func _process(delta):
2020-04-18 22:36:11 +00:00
_networkconnection.process(delta)
var data = _networkconnection.get_server_messages()
#print("******* data:", data.size(), data)
if data.size() > 0:
var ele = data.pop_front()
print("*** ele:" , ele)
func _exit_tree():
2020-04-18 22:36:11 +00:00
print("[net_low_level] End")
disconnect_server()
_networkconnection.terminate_network_connection()
_referentialmessage.clear_session()