Hi everyone,
I’m in need of advice in what to do next.
I have been trying out Defold for a period of time and had successfully developed a simple multiplayer game using luasocket. Recently, I have posted a question about database but in midst of finding a solution, I hit another wall.
The game I created currently is Server-Client relationship where I just simply open a room (open the game as server), then use another device to connect to the room (open the game as client).
Now I wanted to create a lobby system for the client to choose the room to enter in which also will display the room information like how many players are in it. But I have no idea where to start from but I will just say out what I thought of as of now.
Let’s say I have the server machine set up, I will open up 100 instances of the game as server with different port numbers. I will need to create an application like a lobby manager to read off data from each instances, after that when client open the game, it will communicate with this lobby manager so to choose the room the user want and join (which upon choosing the room, the lobby manager will send the port numbers for the client to connect). As lobby manager and all the rooms will be operated on 1 PC, thus they will use the same IP address, just different port numbers for each room.
The idea of manually open 100 instances of the server already put me off (can be done using Batch Job but it’s just weird to me), so I am wondering is there anyway I can combine the lobby and the server into 1 application? I have no experience in network game development so I am not sure what’s the right approach.
Greatly appreciate if someone can provide me some guidance. Thanks in advance.
Hi hmfafordev. Let me see if I can be to any help. We at Strangequest are working with a multiplayer game as well (for the first time
) and have gone through some of your issues already but in the end decided to play it “simple” and “efficient”.
First of all, writing these kinds of things are somewhat complex. Your approach can be done but is not very scaleable in the end. What if you can only push 20 instances on one server. Would you start up a new one with the same procedure? What if it will only be crowded 2 hours a day but only use 10 instances during night etc.
If you really would like to write all this (and host this) by yourself I would suggest at least some kind of “lobby” that not only knows about the instances but starts up and shuts down them as needed. This means that the lobby manager itself maybe cannot be written in Defold (but if you really want it definitely can be written as a pure Lua script). The rest (ports and ip) sounds just about right but it is quite complex fast. You will need to keep track of the “health” of the instances. Which users are where, message back and forth about their connectivity.
We chose not to go this route but to use already existing services out there. Amazon Gamelift is doing all this for us (and even more) giving us matchmaking, drop-in/drop-out rooms, closed matchrooms, scaling up and down servers AND instances/server as needed, starting the Defold binary with all run settings we give it etc etc.
We combined this with Gamesparks backend service which also has matchmaking (that we prefered).
I totally understand if you want to create it yourself. It all depends what you want with your project. Make sure that you actually can run that many instances on one PC and also that the network traffic allows it.
7 Likes
Thanks @andreas.strangequest for the attention and assistance.
I had the same concerns about the performances and the limitation too. That’s what made me stopped at my track.
I didn’t really thought about this though.
Yes, I kinda like to DIY anything that’s possible, the network manager I had are capable of taking the latency into accounts so shutting “unhealthy” room/client are possible at the moment. I was expecting that this Lobby Manager can’t be written in Defold but secretly hoping I was wrong.
At the end of the day, I was trying to see what’s the approach without the use of an existing server services and if my approach are on the right track. But as the complications mentioned, I will probably think twice about it.
I will first read through GameSpark and Amazon GameLift thoroughly to see what’s needed to be implement, as I still not quite understand how these services actually worked.
Thanks once again for the quick but detailed explanation of the possible scenarios.