Answer the question
In order to leave comments, you need to log in
Creating a multi-user server on go?
Task: to make a small multiplayer WEB game.
Description: There are a number of rooms. Each room has a certain number of players. Each player can move WASD + shoot. When a player is hit, the player disappears.
Questions:
1) since we do it via the WEB, do we use web sockets? Are there any other interesting and practical options for my purpose? Also, are you interested in the maximum number of players? As I understand it, this is 64k people per server? Or not?
2) How should the rooms be divided? Do everything in one instance or for each room its own? Store on one server or for each room its own?
3) If on different instances (or actually servers), then how do you eventually connect people to them? In the database to store the port of the room on the server or something else?
4) When starting a GO instance, how to save and manipulate it? How to tell players which one to connect to?
5*) How does Agar.io work? If you open the WS tab, then it is empty there, how do clients communicate?
6*) Where and what can you see about the architecture of such applications?
PS. By instance, I'm talking about a running
PPS application binary. Here the question is specifically about the logic of creating a server, and not a game in particular (but if this is important, then this is 2D with a top view)
Answer the question
In order to leave comments, you need to log in
Go is a general purpose language, so anything is possible.
Its advantages are in its simplicity. One binary, that is, everything is fine
1) since we do it via the WEB, do we use web sockets? Are there any other interesting and practical options for my purpose? Also, are you interested in the maximum number of players? As I understand it, this is 64k people per server? Or not?
2) How should the rooms be divided? Do everything in one instance or for each room its own? Store on one server or for each room its own?
3) If on different instances (or actually servers), then how do you eventually connect people to them? In the database to store the port of the room on the server or something else?
4) When starting a GO instance, how to save and manipulate it? How to tell players which one to connect to?
Creating a multi-user server on go? Task: to make a small multiplayer WEB game.I don't see any obstacles. There are much more complex projects in this language.
1) since we do it via the WEB, do we use web sockets?This is the business of the owner. You can at least do it on webRTC.
Also, are you interested in the maximum number of players? As I understand it, this is 64k people per server?Looking what will be servers. Servers don't care how many players they have.
2) How should the rooms be divided? Do everything in one instance or for each room its own?Not at the MVP level. Let it work somehow. Then, as it grows, it is desirable to scatter. In order to be able to balance the load: in one room it may be empty, in another it is dense and it is necessary to somehow provide resources flexibly.
3) If on different instances (or actually servers), then how do you eventually connect people to them? In the database to store the port of the room on the server or something else?There is a synchronous option, there is an asynchronous one. But it's better to build an MVP. And then look at the options. Too many potential nuances to take into account.
4) When starting a GO instance, how to save and manipulate it? How to tell players which one to connect to?This is about orchestration. There is one project just on Go that does this.
PS. By instance, I'm talking about a running application binary.Instance is usually about some environment of a running application. It can be a virtual machine (in the context of Amazon), or a Docker container, as is now fashionable.
Regardless of the choice of language, there are important problems to solve and a solution to choose from, in practice there are two approaches to creating a game:
1. the game loop is launched on the clients, the server acts as a manager, synchronizes and validates data from the clients. A lot of problems due to desynchronization (character bobbing back and forth) but 'pleasant' realtime (this is an illusion, the lags are just masked)
2. the game loop is launched on the server, clients connect and request how the world looks at the current moment. This is a laggy option (not suitable for dynamic games) but no synchronization problems
In any case, sockets are needed for real-time games (the server must somehow inform clients about changes). The first implementation method may allow the use of webrtc, which can significantly reduce lags but complicate the validation algorithms from cheaters.
There is an ideological way to combine both approaches, making the second dominant, and the first approach will be responsible for displaying information, the client himself will compare the worlds that each approach generates in real time and make a correction if there is a discrepancy.
In practice, many developers spit on validation, write how it will turn out (for example, they take a single-player engine that does not check anything like an old unreal engine, saw AAA MMRPG based on it and then get cheaters who cast any skills with any class or fly or go through walls and etc.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question