netfox icon indicating copy to clipboard operation
netfox copied to clipboard

DO NOT MERGE - ChannelManager research for issue 160

Open warsang opened this issue 11 months ago • 0 comments

This is related to https://github.com/foxssake/netfox/issues/160 and just shows an example/toy implementation for research purposes. Unfortunately, this example doesn't work (and I'm not sure why) so please do not merge it. I mostly wanted to take a shot at supporting channels but not being super familiar with Netfox code, I wasn't able to pull it off. I still wanted to share the work to at least give an idea of what work would be required to get channel support for Netfox.

By default, Godot uses 3 channels for each transfer mode. The below ChannelManager is a bit naive, it should probably keep 1 channel per node instead of assigning one per rpc function meaning we call NetworkTime._channel_manager.get_channel() only once per node and assign that channel to all RPCs in the node. I think that approach would probably work better with unreliable/unreliable_ordered transfer modes?

We implement a channelManager that is instantiated in NetworkTime. -> (Is that the right place to instantiate this? ) When the ChannelManager is enabled, we call rpc_config instead of @rpc decorators for rpc functions because the channel argument in the decorator needs to be a constexpr. The reason we do that is because you apparently can't call a method in @rpc . The get_channel method assigns a channel to the method from a pool of available channels. We could subscribe to network events to assign/free channels in the pool if we get new synchronizer nodes or some are removed (peer disconnects etc.) ;

warsang avatar Feb 14 '25 21:02 warsang