Skip to content
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

Replace party ready check with match confirmation #607

Open
Askaholic opened this issue Jun 18, 2020 · 20 comments · May be fixed by #608
Open

Replace party ready check with match confirmation #607

Askaholic opened this issue Jun 18, 2020 · 20 comments · May be fixed by #608

Comments

@Askaholic
Copy link
Collaborator

Askaholic commented Jun 18, 2020

Overview

For the purposes of a matchmaker it makes more sense to perform the "are players ready to start" check when a match is found instead of when the party is entered into the queue. I suggest that we add a match_info message that look something like this:

{
    "command": "match_info",
    "expires_at": "2020-06-18 20:30:26.677218",
    "players_total": 4,
    "players_ready": 1,
    "ready": false
}

Where expires_at is a timestamp in ISO format and ready refers the the ready state of the player that the message is being sent to (this way the client can synchronize its UI state with the server).

The client can display this information and provide a "Ready up" button. When a player clicks the button, the client will send a match_ready command that will look something like this:

{
    "command": "match_ready"
}

Once all players have readied up, the server will start the match launching procedure. If some players fail to ready up by the expiry time (say 20 seconds from when the match was found) then the match will be cancelled, the server will send a match_cancelled message and return both searches to the matchmaker queue (notifying the client with a search_info command).

Implementation

I suggest writing a small wrapper around a future that will keep track of which players have readied up:

class MatchOffer:
    def __init__(self, players, expires_at):
        ...

    def ready_player(self, player):
        ...

    async def wait_ready(self):
        ...

    def to_dict(self):
        """Return contents of `match_info` message."""

and adding a weak reference to it on the Player objects. Then the player object can also get a method

def ready_match(self):
    ...

which will check if the player has a match offer and proxy the call to ready_player.

Multiqueue support

To support players joining multiple queues at the same time we'll also need to modify the Search object and add a property which signals whether the search should be included in the matching phase, or if it is currently "busy" waiting for players to accept a match offer.

@Askaholic Askaholic added this to To do in Team Matchmaker Jun 18, 2020
@Askaholic Askaholic moved this from To do to In progress in Team Matchmaker Jun 20, 2020
@Askaholic Askaholic self-assigned this Jun 20, 2020
@Askaholic Askaholic moved this from In progress to Review in Team Matchmaker Jun 28, 2020
Katharsas added a commit to Katharsas/server that referenced this issue Aug 8, 2021
Katharsas added a commit to Katharsas/server that referenced this issue Aug 8, 2021
Askaholic pushed a commit that referenced this issue Aug 9, 2021
* Add dummy implementation for client command `match_ready` (#607)

* Add test

* Fx test

* Fix test 2

* Fix test 3
@Katharsas
Copy link
Contributor

Katharsas commented Aug 11, 2021

@Askaholic
Wouldnt it make sense to have the "ready" flag in the message from the client too?

That way it would be possible for the client to detect sombody dropping out (for example by closing the client) and then instesd of everybody having to wait for the timeout, the server could immediately cancel the match.

@Sheikah45
Copy link
Member

There is a ready and unready message

@Sheikah45
Copy link
Member

Wait yeah I see this spec is different. I thought that the messages were the ready_party and unready_party messages as these were put into the client? Not that it matters to much as the name and text can be changed but just making sure.

@Askaholic
Copy link
Collaborator Author

Sounds like a reasonable idea to me.

@Sheikah45
Copy link
Member

So can the ready and unready party commands be removed as they aren't currently used anyway

@Askaholic
Copy link
Collaborator Author

Yea I think so. We were going to repurpose them to solve the issue of not knowing when your party members are in game, but I don't think that will happen anymore. I'd rather solve that issue the right way.

@Katharsas
Copy link
Contributor

Katharsas commented Aug 12, 2021

Soo... what exactly is the conclusion? Keep match_ready? Add flag? Remove the others? And while we are at it, i find the command name a bit confusing, but i guess its really not that important.

@Askaholic
Copy link
Collaborator Author

Now would be the time to change it so feel free to suggest how you think it should work. A flag is probably better that two separate commands.

@Katharsas
Copy link
Contributor

Yeah i feel it would be cleaner with a flag, so like this:

{
    "command": "match_ready"
    "ready": true
}

@Katharsas
Copy link
Contributor

Katharsas commented Aug 21, 2021

What format is this 2020-06-18 20:30:26.677218 exactly? Are there other commands where the client receives a date in this format? From what i can see, an ISO 8601 needs a T intead of a space.

@Askaholic
Copy link
Collaborator Author

Yea it should have a T. Not sure where I got that from, but we should stick to standard ISO format. One thing we learned from using ISO timestamps for matchmaker queue pops is that they lead to bad data sometimes when users system time is misconfigured. So we might want to consider a time delta instead.

@Sheikah45
Copy link
Member

Both never hurts in case of weird delays as well

@Katharsas
Copy link
Contributor

Katharsas commented Aug 22, 2021

Isnt delta time a bit overkill here?
The worst thing that happens is that client doesnt understand that match is expired, should not be a big problem i think. I don't think its reasonable to expect any networking heavy software to behave properly if system time is wrong.

@Askaholic
Copy link
Collaborator Author

Well do you want people complaining on the forums that the match confirmation box is displaying a time of 2 hours or do you not want that to happen...

@Katharsas
Copy link
Contributor

Katharsas commented Aug 22, 2021

Sendiing both relative and absolute times whenever you need to send a time is really the solution to that problem? How often does this problem happen? Should we not make a general check if system clock is correct instead of duplicating all our time fields wherever we go?

The misconfigured time is a problem that lies on a completely different abstraction level than matchmaker code should ever concern itself with, so sending two fields here is just messy.

If the time problem is really a relevant problem than that can be handled with a check that will not start the client at all if time is misconfigured.

@Sheikah45
Copy link
Member

It is for better user experience. Otherwise you have to tell every user who has the issue to set their clock correctly. And locking people out of the client because of a mis-configured system time is definitely not a good thing to do.

@Katharsas
Copy link
Contributor

Telling the user to fix his time settings is much more reasonable than fixing broken time sync in every time related API call that will ever be added to this client. Fixing it in this issue means that you will fix it again and again ein every API to come! Your are increasing, not just code but API complexity, to workaround user level problems, and you are doing it in a way that it will infect all future APIs as well!

@Katharsas
Copy link
Contributor

Katharsas commented Aug 22, 2021

Here is an example for how a much better solution could look like:

  • Have a sync endpoint that you can use to find out by how much the user clock is wrong.
  • Correct all calls that get current time by that drift.
  • Your API can stay simple and clean as it should

Dont get me wrong,, i am not in favor of doing that, i think a simple user facing error is fully reasonable, but at least you don't infect unrelated API endpoints with time problem workarounds.

@Katharsas
Copy link
Contributor

I guess we could just have a relative time in seconds. But having two times (if they conflict you would use the relative time anyway) is just not right.

@Askaholic
Copy link
Collaborator Author

We wouldn't even need to add a time sync endpoint. We could just send the current time in the welcome message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review
Team Matchmaker
  
Review
Development

Successfully merging a pull request may close this issue.

3 participants