0 votes

Recently, my code gave me this error:
Attempt to remote call unexisting ID
I understand this is because the client had disconnected before the rpc_id call. So now, i think there is a problem.
I would technically need to test if a client is still connected before every rpc_id call if i don't want any error, but wouldn't that affect performances ? (especially for constantly sending important data like player position)
All rpc call return an empty variant but i think it could be used to return an Error instead, like the File object.

But for now, what should i do ?

Godot version 3.3
in Engine by (272 points)

1 Answer

0 votes
Best answer

Store your connected peers to a dictionary or array and remove them from said storage on disconnect or use sceneTree's get_network_connected_peers()

Then before an rpc_id call do a verification check

if id in connected_peers:
    rpc_id(id, "send_important_data", data)

Such a check would be in micro seconds an wouldn't affect performance in the slightest

by (4,268 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.