You can use the high-level multiplayer API of Godot, which is explained here: High level multiplayer — Godot Engine (3.0) documentation in English
I would suggest you get familiar with this first.
This will require one of your players to host the trade room, and the other to use the IP address to connect. But you can also make a separate trade server and have both players enter the IP of that server.
If you don’t want them to enter any IP address, then you will have to either hardcode it and make sure the server always run under the same IP, or have an intermediate server (using HTTP for example) which provides the list of available trade servers.
In the case of not entering any IP in a LAN context, you could use network discovery to search for trade servers in your local network (aka an instance of your game that opened a trade peer). I don’t know how that works in detail, but it was mentionned here: https://github.com/godotengine/godot/issues/13947
Thx for your answer. I need to use a LAN system and the first player pressing the connect button would create the trade room. But I’ve two problems :
How can I check if a server is already running so the second player can join it ?
And is there a way to close the server when a trade is done ?
You know if a server runs if it responds to your connection/discovery broadcast. You can never assume a server is always running (even if it should ideally).
Closing a server when the trade is gone is relative. I’d say, your clients have to leave it first, because if the server closes first your clients won’t be gracefully kicked out (depends how you code this, though). Also, if you use a dedicated server or that, it could still be running all the time and handle trades by “sessions”. It’s up to you to decide which flow you want.
I’m new to networking in Godot as well, so I mostly know theory, sorry if I can’t share actual code^^
Zylann | 2018-07-14 13:31
So what are the codes to :
- check if a server is running
- leave the server
(sry I’m lost with network stuff :))