heroiclabs / nakama-godot

Godot client for Nakama server written in GDScript.
Apache License 2.0
593 stars 69 forks source link

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

Open racs4 opened 1 month ago

racs4 commented 1 month ago

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)

linear[bot] commented 1 month ago

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