I want to create a room-based multiplayer game using threads and the high level networking API (preferably)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AlexAndDraw

My goal is to create a Multiplayer Card Game. The General idea is that there is a ‘Matchmaking Lobby’ where all players connect to initially, then it grabs two players and throws them into a room of their own that should be running in an entirely separate thread.

However I am very unclear on how Threads work in some cases here.

  1. If a scene or node is created in a separate thread, is that thread alive until the node is removed or just until it is finished being instanced?

  2. While I could get players into their own room and set up their own ‘game loop’, how do I make sure RPCs (Remote Procedure Calls) exist in that thread? There doesn’t seem to be a clear way to force them into it?

  3. I considered creating two separate threads using the low-level networking for pushing/pulling data, however I have a similar confusion to my above issue. If one of these threads were to push data that emitted a signal, would the receiver of that signal be run in the same thread or would it by default run in the main thread?

Worst case scenario is I can have multiple instances of the server running, with the matchmaking lobby redirecting clients to the relevant port but I’d prefer to avoid this inter-process if possible (or as long as until one process can’t handle anymore threads).

Thank you for reading!

I’ve not done this myself, but cant each room be its own scene instanced under /root? For each player, just hide any room that they are not in (which will also hide the players that are children of that room). The rpc’s will still work because they act on nodes with the same path.

Not sure I see the need for multiple threads or servers.

zdimaria | 2018-03-16 16:00

I’m not concerned about threads, servers etc for sending the relevant actions to the relevant users. I’m concerned about how well the game could scale. What I mean is how far I could get with one thread of logic for multiple games before response times to specific games start to choke because the thread is upheld from earlier responses.

AlexAndDraw | 2018-03-17 21:19

I’m interested to know this as well. Have you ever found out the answer to your question?

godotnoobperson | 2020-08-18 06:33