summaryrefslogtreecommitdiff
path: root/network/login_server.gd
diff options
context:
space:
mode:
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