-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: multiplayer game with server API and more features #8817
Comments
That's a question for @touhidurrr, he built the server at https://github.com/touhidurrr/UncivServer.xyz I have no problem with overhauling the API (current API was basically a MVP for migrating away from Dropbox, hence the FTP-ness) This means one of the following:
I would obviously prefer the former but @touhidurrr also has his own free time restrictions. @GGGuenni has been leading the recent changes for passwords &c so he's more relevant to this than I am Starting with the basics - 'create multiplayer game and allow others to join'.
That's already a lot of work, and this doesn't include issues like
|
why not websocket? |
I'm not against, do whatever feels best to y'all |
Also due to some issues, i am actually rewriting UncivServer.xyz. |
Hey guys, I'm with @CrsiX, nice to hear that you're open to improvements in this regard :)
I'd personally would go for a new implementation, let's call it We're also open for any contributions, regardless if it is code or suggestions regarding API design @touhidurrr and @GGGuenni.
The suggested scope sounds reasonable for a first prototype
I think websockets would greatly improve the load on the server, as there's no "is there any new data?" like requests anymore. I would use an API for the lobby mangement and go for websockets for exchanging the actual game data (and chatting in the later implementation). |
Ok, or let's split this into separate parts and implement them one by one: |
As far as I understand you, @touhidurrr, you "just" want to improve the current multiplayer handling with a few new features (and a server re-write on your side). However, "our" current approach is completely overhauling the whole multiplayer handling. That's why I said earlier:
This includes both server and client. Therefore, the question: do you want to participate in designing and implementing the new architecture? Because splitting the work only makes sense if we pull together. Our server implementation work already started here: https://github.com/hopfenspace/runciv |
Oh, I think I misunderstood the context of the issue. Good work!
I don't know rust, so no. However, I would like to participate on the design aspect of it. I already have many design concepts in my mind for many features like Lobby, Chat, etc. But not as a REST API but as a WebSocket server. Obviously, some endpoints can be REST but overall it is better to avoid REST as a whole to make the mp experience feel more seamless. As polling is not really a pleasant experience for anyone. I guess it is time to write them down and take opinions and start working on them. I guess we can share our design choices and discuss among us to build the best Multiplayer server ever. |
I think this is the data you are looking for: |
Thanks for the insight. Around 100k users is a good value for this game, but no stressful amount for a good server as well. Do you want to join us at the discussion page? :) |
This is monthly statistics, but yes, that is not considered as high volume traffic.
Yes. I read your rust code and there is some things that I would like to talk about. However, I would prefer if for Unciv Multiplayer v2, we discuss a list of features that we would like to implement, open a new issue with a checklist in this repo and then start working on that. Also, @yairm210 from you post #8817 (comment), I am not sure if you want to maintain |
Unciv.jar can die as far as I'm concerned. It was just a temporary hack to demonstrate the API so people who wanted to stop using Dropbox could. |
Like with everything, I'm in favor of burning all the old stuff to the ground - provided that we have a replacement that's been tested and that we can phase out the old gradually. |
I think the following mechanism solves the problem with relatively low effort (at the time the new server is stable and ready):
But what about the server address? It just continues to work. The aforementioned mechanism is a kind of version auto-detection. However, to make things perfectly clear, I would like to introduce a new endpoint: Note that currently we plan to have a completely different user handling. Therefore, this approach requires significant client-side rework (and extension). I'm already looking into it... |
That already exists in the /isalive check, it should already return the version for password-authenticated servers |
Yea I was planing to introduce Websockets with the next server feature: Lobbys I went with the |
An understandable approach. But the number of server developers and server operators is pretty limited, AFAIK. Is it really useful to have long periods of upgrade? You can find our currently implemented API here: https://runciv.hopfenspace.org/docs/ I'm going to implement the PoC mentioned above, so that we can further elaborate the next steps, because it requires a lot of UI work, too. |
You mean the Unciv_Server_.jar included in the main Project - I concur. And that "beer iron" code looks - from a very superficial look - like a significant amount of investment and expertise. |
Unciv Multiplayer v2 Protocol (proposal): Standards: Message format:
Commands & Responses: --Popup --Errors --Accounts [--to be continued] |
@yairm210 @GGGuenni @myOmikron @CrsiX is something like this good enough? in websocket, everyone seems to make their own protocol. but json seems to be commonly used. |
I oppose this proposal for two reasons.
WebSocket has built-in Frame types. Two of them are
This is too generic in my opinion and it makes internationalization harder. I would therefore prefer common codes for all possible messages, so that a) the implementations can use enums for them instead of strings and b) those enums can be translated to all different languages. It would be better to indicate the type of pop-up (e.g. We've also started to work on a WebSocket protocol. It's built on JSON sent via WebSocket {
"type": "string_indicating_the_message_type",
"content": {
// various content based on the message type, which allows for easier parsing by libraries
}
} There are already a few defined types: |
@CrsiX I the main reason for avoiding REST APIs is to avoid polling. Is there any reason of making things complicated by keeping REST API alongside WebSocket? I see no point in that. To ensure a seamless Multiplayer Experience, everything is better to be built on WebSocket from scratch. |
I agree with that, but there should be ways to send popup messages from the server. Maybe we can implement types for that. |
Also kindly use camelCase, they are more readable. |
Could you name me a use case for that feature? |
I kindly disagree with this statement. Websockets are great for working with events that don't use the request / response pattern, e.g. pushing your turn results as one event that is sent to the server. Or pushing this updated state to all the other clients. If you want to force a req/res pattern onto websockets, there are a few downsites doing so:
These are concerns that you don't have, when doing HTTP requests, as they are already solved by the nature of HTTP requests themself.
So I'm totally onboard with you regarding everything that is related to any kind of polling. But things like a register endpoint should be handled the easiest way - with plain old http requests. Normally, I don't like the way how microsoft designs its systems, but this article also makes some additional valid points.
I also disagree with this statement, but as I don't have a strong preference here, fine 4 me. |
This would allow a greater server - user relationship. Things like server events would be possible. |
Also this is too confusing... I am not sure how this will work. Currently Unciv assigns a random UUID to the client upon installation. Now it looks like you are preserving both UUID and username. Now the confusing part is what happens when the user signs up, uninstalls the client, and then tries to log in. What will be the UUID in this case? Will it be the old one or the new one? And if the user has to set a username in the first place then why do we need a UUID? Also what happens to the games that are currently being played? They also have the user ids of the players. I am a bit confused about how this works, can you kindly explain? |
We prefixed everything with
At first, we have decided against such an endpoint:
Of course, the server can be changed. So, if Note: in the current client, I'm checking the |
Sure. So, why a user UUID in the first place? Well, we want to uniquely identify an account. All data associated with an account may change (username, display name, password, games, whatever ...), so that UUID is the anchor to identify the user across the account's lifetime. (The UUID is also the primary key in the database.) How do you map from a username to a UUID? Either you use the dedicated endpoint
We can't let the client decide which UUID it will become on the server, that would just be completely broken. As lined out above, the username (plus password) is used to login. It doesn't matter if it's a new installation, another device, another timeline. The successful authentication provides the UUID. It will then overwrite the UUID of the client. (Yes, this means going back to the old API is currently not possible after first use of the new API. I have a warning popup before the first login which displays the old UUID of the player, so that it's possible to manually reset the UUID.)
There's currently no plan of an "easy" transition from APIv1 to APIv2. You stop/complete all APIv1 games and then start with APIv2. Why that? Because a) we can't let the user decide on any UUIDs and b) it's just a PoC for now. Those transitions can be checked later on. However, playing with APIv2-players only works of course. So if we have player A and player B both registered to our server, they can play the game happily together, because their UUIDs match what's in the game files. (I have tested up to four concurrent players, so I assume it's working with even more reliably.) |
So, it boils down to me needing to make a tool for safe transition of UUIDs. Noted. |
I'm not sure about that yet. It would mean that there's a transition where all "old" user IDs are mapped to "new" user IDs at once. It may be possible, but it's not very easy. Therefore, I suggest to keep all those transitioning stuff on hold for now :) |
Also, @CrsiX can you add a flags parameter to users? like |
What exactly do you mean? What are those flags possibly used for? I assume you want something like different privilege levels, so which feature would need privileges in the first place? We have no privilege system at the moment (except for lobbies, where the owner of the lobby can do more than the members of the lobby, like kicking users and starting the game). |
They would just appear as badges next to user. A cool thing. |
Let's get something working end to end for users before we start expanding into "nice to have"s :) |
But what's the purpose of such a badge? And how would you earn it, who decides which user gets such a badge? Things like moderator or admin need the server operator or an entity with comparable "power" to give & take those badges. IMHO, this is much more complex than it could be useful. If the user could change / set his own badge, then it would be rendered useless (or, purely aesthetically, with no real meaning for the game). |
With this things like Server messages and Server bots would be possible. With verified badges. Also, people often asks me to do stuff like fix broken games, delete games, change user ids, etc. So, I want an admon badge. . Maybe the server can even give exp and levels to users. Things like this make the game more engaging. Anyways, let's launch a working v2 first and then we can maybe add these features. |
Thanks for clarification, I now understand what you meant. Some things are really nice ideas, indeed. :) |
I'm planning on introducing persistence later on. Part of this persistence will be the list of games and their game states, as well as the game chats. Since my data formats need to be different than all currently available data formats in the game, I wanted to introduce a new directory that stores the data specific to those new game mechanics. At the moment, the game saves the following files and directories (afaict):
I want to add a new directory
All of those new persistent data should always be
|
That sounds more like a job for sql(ite) |
Fair. We already discussed it internally. And it is the better alternative, indeed. However, since I didn't dive into Kotlin/SQLite/Android integrations yet, I just came up with the good old JSON. And wouldn't it require yet another dependency? I remember that Android provides some SQLite db for applications, does it? And it would require cross-platform support, of course. Quick searching brings up Exposed as an ORM, for example. I could start by evaluating the support of those/alternatives to integrate them properly into the game, if you don't have something in favor? |
By the way, do you want to check out the current state of our implementation? I've just created an alpha release here. 🎉 You can freely test the new features and user interfaces that I've created there. I'm always open for suggestions and improvements. Just make sure to open any issues related to the new mechanics at our fork. Of course, you can also check out our |
Uh, I don't do multiplayer. But thanks for the confidence. I can confirm that checking out your branch builds and runs perfectly fine - and I see no difference, that's how good I know the MP side of Unciv. Besides, I redirect server to a not-open port on localhost to silence all that chatter (& less stutter in single-player gaming). 🤷 |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days. |
Dear GitHub Actions bot, even though I was inactive, I currently still plan to bring this feature into existence at some point in the future :) |
Hi everyone, (ping @yairm210 @SomeTroglodyte ). This issue has been open for a long time and nobody else stepped up to continue working on it (somewhat expected). I know that I said I would continue working on it, but due to time constraints I did not. Is there interest from your side to continue pursuing a nice multiplayer experience? (The server code at https://github.com/hopfenspace/runciv has been updated yesterday and is fully functional again. The server we had hosted a year ago has been shut down, though.) |
Actually I did, but my goals and approach both were totally different. Mostly because of me not wanting to invest a lot of time in learning Kotlin, Java / Kotlin ecosystem, libGDX etc. I guess). My approach is here (funny but also fully functional). I actually had a lot of interest in Multiplayer v2 and I might have been able to contribute more strongly if my skills in this ecosystem was better. Anyways. although these are different, let me know if you can make these two compatible. That's all. spoilerActually it is not really v2, but somewhat between v1 and v2 I guess? Maybe v1.1? You can consider implementing this in Unciv before moving into v2 also I guess. |
I think you can try standardizing WebSocket on Unciv first then gradually keep adding new features on top of it like suggested before. For example, if just games were passed on top of a WebSocket protocol instead of HTTP, we would have an in-game chatting system already. That is certainly one way to go. |
Hi, we really like the game but the multiplayer functionality just sucks, sorry. (And the server is pretty ... hacky. Maybe a plain FTP server would have been a better choice).
Therefore, we would like to put our hands on a new multiplayer service. We essentially build our own server (in Rust) while also hooking the relevant client functionality. Additionally, we integrate feature requests such as the following:
However, we would like some help on integrating some of the stuff in the client app. For example, we build the server and the API and all of the network-related code, while someone else could jump in to tweak the user interface to make use of the newly available features (e.g. chatting or username/password instead of UUIDs).
Side question: how many people are currently using your public multiplayer service? A rough approximation (20 a day or 20k a day)?
The text was updated successfully, but these errors were encountered: