diff options
Diffstat (limited to 'network')
-rw-r--r-- | network/character_server.gd | 15 | ||||
-rw-r--r-- | network/login_server.gd | 16 | ||||
-rw-r--r-- | network/map_server.gd | 4 | ||||
-rw-r--r-- | network/server.gd | 17 |
4 files changed, 50 insertions, 2 deletions
diff --git a/network/character_server.gd b/network/character_server.gd index 4831b36..ec0aadb 100644 --- a/network/character_server.gd +++ b/network/character_server.gd @@ -56,3 +56,18 @@ func select_character(slot: int): if packet is CharacterSelectionSuccessPacket: print(inst_to_dict(packet)) selected_character.emit(packet) + + +func get_keep_alive_timer() -> Timer: + var character_server_keep_alive_timer = Timer.new() + character_server_keep_alive_timer.name = "CharacterServerKeepAliveTimer" + character_server_keep_alive_timer.autostart = true + character_server_keep_alive_timer.one_shot = false + character_server_keep_alive_timer.wait_time = 12.0 + + character_server_keep_alive_timer.timeout.connect(func(): + var character_server_keep_alive_packet := CharacterServerKeepAlivePacket.new() + send(character_server_keep_alive_packet) + ) + + return character_server_keep_alive_timer diff --git a/network/login_server.gd b/network/login_server.gd index 238a183..a78f750 100644 --- a/network/login_server.gd +++ b/network/login_server.gd @@ -21,3 +21,19 @@ func login(username: String, password: String): if packet is LoginServerLoginSuccessPacket: print(inst_to_dict(packet)) logged_in.emit(packet) + + +func get_keep_alive_timer() -> Timer: + var login_server_keep_alive_timer = Timer.new() + login_server_keep_alive_timer.name = "LoginServerKeepAliveTimer" + login_server_keep_alive_timer.autostart = true + login_server_keep_alive_timer.one_shot = false + login_server_keep_alive_timer.wait_time = 30.0 # 60.0 + + login_server_keep_alive_timer.timeout.connect(func(): + var login_server_keep_alive_packet := LoginServerKeepAlivePacket.new() + login_server_keep_alive_packet.user_name = "dweipert" + send(login_server_keep_alive_packet) + ) + + return login_server_keep_alive_timer diff --git a/network/map_server.gd b/network/map_server.gd index 1f74055..cf6f2ad 100644 --- a/network/map_server.gd +++ b/network/map_server.gd @@ -19,8 +19,8 @@ func login(account_id: int, character_id: int, login_id1: int, gender: Constants peer.put_data(map_server_login_packet.to_bytes()) - peer.get_data(6) # in-between packet - peer.get_data(4) # in-between packet + peer.get_data(6) # in-between packet # 0x0283 + peer.get_data(4) # in-between packet # 0x0b18 var packet = await received_packet if packet is MapServerLoginSuccessPacket: diff --git a/network/server.gd b/network/server.gd index e46e797..8b41b4f 100644 --- a/network/server.gd +++ b/network/server.gd @@ -35,10 +35,27 @@ func listen() -> void: raw_packet += packet_length raw_packet += peer.get_data(packet_length.decode_u16(0) - 4)[1] + prints("Upcoming Length:", packet_length.decode_u16(0), "for =>") var packet = packet_type.from_bytes(raw_packet) received_packet.emit(packet) + + var display_header = raw_packet.slice(0, 2) + display_header.reverse() + print("Received known packet with header ", display_header.hex_encode(), " = ", packet_type.get_global_name()) else: raw_packet.reverse() print("Received unknown packet with header ", raw_packet.hex_encode()) + + +func send(packet: Packet) -> Error: + var display_header = packet.get_header() + display_header.reverse() + print("Sent packet with header ", display_header.hex_encode()) + + return send_raw(packet.to_bytes()) + + +func send_raw(bytes: PackedByteArray) -> Error: + return peer.put_data(bytes) |