-
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
Multiplayer APIv2 #9497
base: master
Are you sure you want to change the base?
Multiplayer APIv2 #9497
Conversation
…o server feature set
This is mandatory since for API v2, the server will create and validate the game UUIDs. Generating them on the client is therefore no viable solution.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I'm curious. The
I can't finally answer those two questions just by reading docs & code. Thanks :) |
As far as I know, in the end, the actual "executor" of such a block would be - for desktop - in this source line - you'll see a synchronized un-stack, but that's all. It's inside the application class'es loop() method, which as far as I know simply ticks with typically 60fps, calls draw, actions.act and so on... So that would make a "Yes, Yes"??? I haven't read the other backends though. |
If we put our trust into StackOverflow answers here, then it's also single-threaded on Android. I will just try implementing it that way and see if it works or not. |
Never. Trust. Anybody. Hmmm... Noo, too weak as a joke. Anyway, here's confirmation - they're called from the actual frame render routine. Interesting, however, that they suppress any exceptions there and only log them, while desktop does no such thing.. |
It enforces the use of the OpenGL render thread for synchronization instead of mutexing.
GL is single threaded always because that's how G |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
If you say you're still working on this, I'll trust you and leave this to not stale (unless Yairm) objects to the label here as well). If noting else, someone could grab most of the work and probably implement it |
It's fine if this PR gets closed by the bot if you ask me. The work I have done is still there; and since it was unreviewable due to size back then, I would need to break it down into smaller components that can be integrated one by one -- this is the tricky part. And since I haven't touched it in half a year, it will be a mess for me just as for anyone else (but if anyone actually wants to touch it, feel free) :D |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Lol. Whats the purpose of will not stale tag then? |
Huh... I bet the will not stale tag is only applying to issues and not PRs |
This may be a larger PR and I'm open to suggestions. Please read on.
Highlights
What it does
This PR introduces a new library (
ktor
) and sub-package that speaks with our new multiplayer server, as well as a lot of new UI elements that make use of those new API features, bundled with some new events to integrate the WebSocket smoothly. It already comes with a new Android turn checker as well. For more details, see #8817.We have carefully checked the new experience. It works pretty well, except for the list of bugs and other issues I created at our fork. Most importantly, I don't want to break backwards-compatibility with APIv0 and APIv1 (that's how I started to call the Dropbox and all the Dropbox-replacement servers, respectively). That means: at the game start (as well as on server change), the server is queried for the
/isalive
endpoint to determine if it's an "old-style" server. If not (response code400
), it is checked for/api/version
. Only if theapiVersion
can be matched, you will see the new features. Otherwise, everything should stay the way it currently is: players would not see any difference if they don't use a new APIv2-compatible server.Note, however, that the servers are not compatible for a specific game. At the moment, you can't create a game in APIv1 and continue playing in APIv2 (or vice versa), and there are no plans to allow that, yet. That means: a party needs to decide on a server to play on beforehand.
API
I bundled all the details in
com.unciv.logic.multiplayer.apiv2
. It includes the main classAPIv2
, which holds a lot of other stuff besides the core functionality, which resides inAPIv2Wrapper
. Accessing functionality is possible like so:UncivGame.Current.onlineMultiplayer.api.auth.login
to use the login endpoint, for example. There's alsoApiV2FileStorageEmulator
which enabled in-place usage of the new functionality whenever the current APIv0/APIv1 would be used (e.g. saving/loading games).The "game preview" mechanism is not used at all. The server holds a counter
dataID
, which is incremented every time some player uploads a new game. Checking the value of that counter is enough to detect changed game states.UX
There are a bunch of new screens, buttons, tables and other elements around. Some important screens:
LobbyBrowserScreen
when you click on "multiplayer" in the main menu, which provides a list of your current games and all open lobbies of the current server, as well as buttons to create lobbies, manage friends, ...MultiplayerGameScreen
which you see when you click on the multiplayer button of theWorldScreen
, providing the chat, player operations, access to the friends and recent gamesLobbyScreen
which replaced theNewGameScreen
for our purposes here, it also holds a chat windowThe user is usually notified by popups about incoming events (e.g. new chat message, lobby invitation, a friendship request, ...).
Missing things
Take note
OnlineMultiplayer
now, so that everything is cleaned up properly.NewGameScreen
will use horizontally aligned picker buttons instead of vertically aligned as before (provides much more screen space).apiv2
package stuff out, but that didn't work out easily.cc @SomeTroglodyte @touhidurrr
If you checkout and build, I suggest the following patch (it provides better debugging experience when testing on multiple devices):