From e8aa9f50886b66d525307a58d71036e6fd3d4aa1 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 28 Nov 2024 18:38:42 +0100 Subject: next commit --- network/login_server.gd | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 network/login_server.gd (limited to 'network/login_server.gd') diff --git a/network/login_server.gd b/network/login_server.gd new file mode 100644 index 0000000..bb7c093 --- /dev/null +++ b/network/login_server.gd @@ -0,0 +1,31 @@ +class_name LoginServer + + +var host: String +var port: int = 6900 +var stream: PacketPeerStream = PacketPeerStream.new() +var peer: StreamPeerTCP = StreamPeerTCP.new() + + +@warning_ignore("shadowed_variable") +func _init(host: String, port: int = 6900) -> void: + self.host = host + self.port = port + + stream.stream_peer = peer + peer.connect_to_host(host, port) + peer.poll() + + +func login(username: String, password: String) -> LoginServerLoginSuccessPacket: + var login_server_login_packet = LoginServerLoginPacket.new() + login_server_login_packet.username = username + login_server_login_packet.password = password + + peer.put_data(login_server_login_packet.to_bytes()) + + var success = LoginServerLoginSuccessPacket.from_bytes_via_peer(peer) + var character_server_information: CharacterServerInformation = success.character_server_information[0] + print(inst_to_dict(success), inst_to_dict(character_server_information)) + + return success -- cgit v1.2.3