Switched from UDP to TCP-based connection; implemented creating, joining, leaving lobbies
This commit is contained in:
@@ -1,2 +1,63 @@
|
||||
class_name ClientInterface
|
||||
extends Control
|
||||
|
||||
@export var client: WebClientTCP
|
||||
|
||||
@export var connect_button: Button
|
||||
@export var create_lobby_button: Button
|
||||
@export var join_lobby_button: Button
|
||||
@export var leave_lobby_button: Button
|
||||
|
||||
@export var name_input: LineEdit
|
||||
@export var lobby_code_input: LineEdit
|
||||
|
||||
func _on_create_lobby_button_pressed() -> void:
|
||||
client.create_lobby(name_input.text.strip_edges())
|
||||
|
||||
create_lobby_button.disabled = true
|
||||
join_lobby_button.disabled = true
|
||||
leave_lobby_button.disabled = false
|
||||
|
||||
name_input.editable = false
|
||||
lobby_code_input.editable = false
|
||||
|
||||
func _on_connect_button_pressed() -> void:
|
||||
connect_button.disabled = true
|
||||
client.connect_to_server()
|
||||
|
||||
create_lobby_button.disabled = true
|
||||
join_lobby_button.disabled = true
|
||||
leave_lobby_button.disabled = false
|
||||
|
||||
func _on_join_lobby_button_pressed() -> void:
|
||||
client.join_lobby(lobby_code_input.text.strip_edges(), name_input.text.strip_edges())
|
||||
|
||||
func _on_disconnect_lobby_button_pressed() -> void:
|
||||
leave_lobby_button.disabled = true
|
||||
client.leave_lobby()
|
||||
|
||||
func _on_web_client_tcp_connected_to_server() -> void:
|
||||
create_lobby_button.disabled = false
|
||||
join_lobby_button.disabled = false
|
||||
|
||||
name_input.editable = true
|
||||
lobby_code_input.editable = true
|
||||
|
||||
func _on_web_client_tcp_connection_error_occurred() -> void:
|
||||
connect_button.disabled = false
|
||||
|
||||
func _on_web_client_tcp_disconnected_from_server() -> void:
|
||||
create_lobby_button.disabled = true
|
||||
join_lobby_button.disabled = true
|
||||
leave_lobby_button.disabled = true
|
||||
|
||||
name_input.editable = true
|
||||
lobby_code_input.editable = false
|
||||
lobby_code_input.text = ""
|
||||
|
||||
|
||||
func _on_web_client_tcp_connected_to_lobby(lobby_id: String) -> void:
|
||||
lobby_code_input.text = lobby_id
|
||||
|
||||
func _on_web_client_tcp_disconnected_from_lobby() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
Reference in New Issue
Block a user