summaryrefslogtreecommitdiff
path: root/network/login_server.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-28 18:38:42 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-28 18:38:42 +0100
commite8aa9f50886b66d525307a58d71036e6fd3d4aa1 (patch)
treece6f59eecf1eb3e1ba2794166c09623d8a2d7d83 /network/login_server.gd
parentc89f25f59aa493d95bcac8e75ca5cdd57a0403e7 (diff)
next commit
Diffstat (limited to 'network/login_server.gd')
-rw-r--r--network/login_server.gd31
1 files changed, 31 insertions, 0 deletions
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