summaryrefslogtreecommitdiff
path: root/network/login_server.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-30 12:46:08 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-30 12:46:08 +0100
commitd560f77811d4fc6f29bf477356a6d2e58dda0be1 (patch)
tree3ac2c4267b5c88e40849416115977574e9f09a83 /network/login_server.gd
parent313afffce7a823c30acf4853b083f9ca5132e879 (diff)
next commit
Diffstat (limited to 'network/login_server.gd')
-rw-r--r--network/login_server.gd27
1 files changed, 2 insertions, 25 deletions
diff --git a/network/login_server.gd b/network/login_server.gd
index 6d878c4..238a183 100644
--- a/network/login_server.gd
+++ b/network/login_server.gd
@@ -1,36 +1,13 @@
class_name LoginServer
+extends Server
-signal received_packet(packet: Packet)
signal logged_in(packet: LoginServerLoginSuccessPacket)
-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()
-
-
-## Emits [signal received_packet].
-func listen() -> void:
- if peer.get_status() == StreamPeerTCP.Status.STATUS_CONNECTED:
- var raw_packet: PackedByteArray = peer.get_partial_data(2)[1]
- if raw_packet.size() > 0:
- raw_packet += peer.get_data(peer.get_available_bytes())[1]
- var header = raw_packet.decode_u16(0)
- var packet_type = Constants.PacketDB[header]
- var packet = packet_type.from_bytes(raw_packet)
-
- received_packet.emit(packet)
+ super._init(host, port)
func login(username: String, password: String):