Join, Return failed or successful #8

Open
opened 2020-06-26 21:10:18 -04:00 by drraccoon · 1 comment
Owner

When player attempts to join a game, return if it was sucessful or failed. This'll allow us to properly display dialog box if it failed, or if it worked, pass the player into the lobby.

When player attempts to join a game, return if it was sucessful or failed. This'll allow us to properly display dialog box if it failed, or if it worked, pass the player into the lobby.
drraccoon changed title from Join, Return failed or sucessful to Join, Return failed or successful 2020-06-26 21:10:26 -04:00
drraccoon added this to the Confirm Hosting is actually working milestone 2020-06-26 21:10:32 -04:00
drraccoon added the
enhancement
label 2020-06-26 21:11:21 -04:00
Author
Owner

f298ca909c


Currently, the game has a button "join game" connected to a signal, this triggers func join_game() which calls:

var host = NetworkedMultiplayerENet.new()
host.create_client(ip, port)
get_tree().set_network_peer(host)
print("I think I connected??")

Although, there is no checks (yet) to return if a server was found at that IP address and port. Implementation was attempted by doing:

var host = NetworkedMultiplayerENet.new()
var joinresult = host.create_client(ip, port)
if (joinresult==OK):
	get_tree().set_network_peer(host)
	print("Netplay - It worked! I should be connecting...")
else:
	print("Netplay - I was unable to connect to the server.")

But host.create_client(ip, port) returns 0 when connecting to nothing, and when connecting to a known server... Its possible that returning a result off that call isnt the proper way to do this?

See also, https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html#initializing-the-network

I did create some signal connections withbuiltin functions:

func _ready():
	get_tree().connect("connected_to_server", self, "_connected_ok")
	get_tree().connect("connection_failed", self, "_connected_fail")

But they're not working / firing.

func _connected_ok():
	print("Netplay - Built-in Signal - It worked! Im connected!")

func _connected_fail():
	print("Netplay - Built-in Signal - It failed")

Current progress can be found in latest commit (f298ca909c)

https://git.valter.cat/drraccoon/GD-Polo/commit/f298ca909c7734c40e444d34a0f831263d06a28c ----- Currently, the game has a button "join game" connected to a signal, this triggers func join_game() which calls: ```go var host = NetworkedMultiplayerENet.new() host.create_client(ip, port) get_tree().set_network_peer(host) print("I think I connected??") ``` Although, there is no checks (yet) to return if a server was found at that IP address and port. Implementation was attempted by doing: ```go var host = NetworkedMultiplayerENet.new() var joinresult = host.create_client(ip, port) if (joinresult==OK): get_tree().set_network_peer(host) print("Netplay - It worked! I should be connecting...") else: print("Netplay - I was unable to connect to the server.") ``` But `host.create_client(ip, port)` returns 0 when connecting to nothing, and when connecting to a known server... Its possible that returning a result off that call isnt the proper way to do this? See also, https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html#initializing-the-network I did create some signal connections withbuiltin functions: ```go func _ready(): get_tree().connect("connected_to_server", self, "_connected_ok") get_tree().connect("connection_failed", self, "_connected_fail") ``` But they're not working / firing. ```go func _connected_ok(): print("Netplay - Built-in Signal - It worked! Im connected!") func _connected_fail(): print("Netplay - Built-in Signal - It failed") ``` Current progress can be found in latest commit (https://git.valter.cat/drraccoon/GD-Polo/commit/f298ca909c7734c40e444d34a0f831263d06a28c)
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: drraccoon/GD-Polo#8
No description provided.