nakama-godot icon indicating copy to clipboard operation
nakama-godot copied to clipboard

Question: What would be the best way to write a "pop_statistic" to a nakama relay server?

Open racs4 opened this issue 7 months ago • 1 comments

If you're using godot multiplayer the "standard" way, you will use a ENetMultiplayerPeer in an ENetConnection. With this you can create

func get_received_data():
	var enet_connection = multiplayer.multiplayer_peer.host
	var data_received = enet_connection.pop_statistic(ENetConnection.HOST_TOTAL_RECEIVED_DATA)
	return data_received

func get_sent_data():
	var enet_connection = multiplayer.multiplayer_peer.host
	var data_sent = enet_connection.pop_statistic(ENetConnection.HOST_TOTAL_SENT_DATA)
	return data_sent

and add on the _ready of your main you can write:

func _ready():
        Performance.add_custom_monitor("Network/Received Data", get_received_data)
        Performance.add_custom_monitor("Network/Sent Data", get_sent_data)

to get received and sent bandwidth on the debugger profiler.

What would be the correct/best way to get something like this using NakamaMultiplayerBridge. On multiplayer.multiplayer_peer I have a NakamaMultiplayerPeer which has a Packet class inside of it. Getting the size of the last packet generated would be enough? (Maybe all that I'm writing here is bullshit - I'm new in game dev - , but if it is please let me know)

racs4 avatar Jul 23 '24 01:07 racs4