Boardgame.io: Update Match ID and Match Unlisted using React Client

Created on 26 Jan 2021  路  4Comments  路  Source: boardgameio/boardgame.io

I can't find a way to update match Id and also update match unlisted attribute to true.

According to this document we can update the matchID in Plain JS Client with

updateMatchID(id)

How can I achieve this with React client?

question

All 4 comments

Using a React client you can set the matchID to connect to by passing it as a prop:

<Client matchID="my-match-id" />

If the prop changes, the client will reload and use the new matchID.

unlisted is an option when creating a match using the Lobby API, so you can鈥檛 set it directly on a client, instead you have to send it as part of the create match request.

Facing the same issue, how can we unlist a match after match creation, lets say like once the number of players connected to a match is full ?

So how do I stop the match from being listed after all the players have joined the lobby? Do you know how others are handling this case?

Ah, there鈥檚 no way to change unlisted currently. Are you trying to only display matches with open spaces? If you鈥檙e looking for a way to do that, I would do something like this on the client:

const hasEmptySeat = (match) => match.players.some(player => !player.name);
const openMatches = matches.filter(hasEmptySeat);

unlisted was intended mainly to allow clients to create a match that is _never_ listed. The create endpoint returns a matchID, so you can then do something like share a URL with that ID so only friends have access to the match.

Assuming you are trying to only list open matches, what might make more sense would be to extend the match listing functionality, so it would be possible to request only matches that aren鈥檛 full (similar to what #740 implemented for time and gameover queries).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicolodavis picture nicolodavis  路  4Comments

nicolodavis picture nicolodavis  路  7Comments

alexwoodsy picture alexwoodsy  路  7Comments

eseom picture eseom  路  4Comments

adngdb picture adngdb  路  5Comments