Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Xrayez |
To enable networking, one has to provide networking peer to the SceneTree
, mostly by initializing NetworkedMultiplayerENet
for creating servers and clients and be able to use high-level networking capabilities. Is it possible to use such a peer to do low-level networking along with RPC system as well (since it inherits PacketPeer
)? I mean something like this:
func _process(delta):
var peer = get_tree().network_peer
if peer:
if is_server():
for peer_id in players:
if buffer.size():
multiplayer.send_bytes(packet, peer_id)
buffer.resize(0)
else if is_client():
while peer.get_available_packet_count():
var packet = peer.get_packet()
The reason I’m asking is that I stumbled upon a problem sending large data to network peers (in order to sync game world). The data size can range from 500kb to 5mb.
I tried to call RPC method with my data being nested Dictionaries
with values including PoolByteArrays
, but the client hangs. The reason for this is probably that the packet size might be too big to be handled by RPC system… Do I have to create additional PacketPeerUDP
or something similar for handling large data transfering? I’m somewhat new to networking so feel free to enlighten me on the topic.
I would always chunk the data when udp is involved and if it exeeds lets say 255 bytes.
But on the other hand, since we have enet, maybe try to “reliably” send your data.
Try to also compress your data first.
David Krause | 2018-07-09 10:33
Oh yeah I’ve even compressed my data but it still exceeds packet size. Seems like data chunking is the most logical solution… could probably use high-level networking for that too. Need to read up on the topic more.
Xrayez | 2018-07-09 10:38