Skip to content

Remove comment of _synced_clients#310

Closed
TheYellowArchitect wants to merge 1 commit intofoxssake:mainfrom
TheYellowArchitect:patch-1
Closed

Remove comment of _synced_clients#310
TheYellowArchitect wants to merge 1 commit intofoxssake:mainfrom
TheYellowArchitect:patch-1

Conversation

@TheYellowArchitect
Copy link
Copy Markdown
Contributor

@TheYellowArchitect TheYellowArchitect commented Oct 18, 2024

Solves #184

The comment is misleading. There is no RPC re-sending anywhere in the code, nor is this variable used for checking re-sent RPCs.

The comment is misleading. There is no RPC re-sending anywhere in the code, nor is this variable used for checking re-sent RPCs.
@TheYellowArchitect TheYellowArchitect changed the title Remove comment from _synced_clients Remove comment of _synced_clients Oct 18, 2024
@elementbound
Copy link
Copy Markdown
Contributor

Please tell me more about this PR. I've added the comment originally because the RPC method seemed to be called multiple times. This PR removes the comment and says nothing about any findings.

@TheYellowArchitect
Copy link
Copy Markdown
Contributor Author

I didn't find any RPC being re-sent in all my tests and PRs and debuggings. I didn't test specifically for this, but I am confident my loggers would have caught a duplicate RPC. Feel free to close this if you suspect duplicate RPCs still exist 👍

@elementbound
Copy link
Copy Markdown
Contributor

Changed NetworkTime's _submit_sync_success() to the following:

@rpc("any_peer", "reliable", "call_remote")
func _submit_sync_success():
	var peer_id = multiplayer.get_remote_sender_id()
	
	if not _synced_clients.has(peer_id):
		_synced_clients[peer_id] = true
		after_client_sync.emit(multiplayer.get_remote_sender_id())
		_logger.info("Peer %s is synced" % [peer_id])
	else:
		_logger.warning("Peer %s is synced again" % [peer_id])

Resulting logs:

[DBG][@42][#1][netfox::NetworkTime] Client #1524895070 is now on time!
[INF][@42][#1][netfox::NetworkTime] Peer 1524895070 is synced
[WRN][@42][#1][netfox::NetworkTime] Peer 1524895070 is synced again

Unfortunately the _submit_sync_success() method is triggered twice, and based on the code, it is only ever called through an RPC. So this issue seems to persist, closing PR.

Fixes still welcome though!

@TheYellowArchitect
Copy link
Copy Markdown
Contributor Author

TheYellowArchitect commented Nov 14, 2024

The RPC is not triggered twice, the codeblock sending the RPC is.
triggered-twice

The above image is with only a server and a client.

@TheYellowArchitect
Copy link
Copy Markdown
Contributor Author

TheYellowArchitect commented Nov 14, 2024

I found the source of the problem: NetworkTime.start() starts twice. See
double-start-network-time

By removing the highlighted code (at join() as well), everything works smoothly.

There are many solutions for this issue. The easiest solution is to put a boolean has_started inside NetworkTime.start() so when it detects true, it returns. lol this already exists with _active, but it doesn't become true in time, because of the await race condition.

Edit: Fixed in below PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants