Hi,
I’m developing a real-time multiplayer game and I’m using:
- C++ & cocos2d-x 3.17.2
- Nakama Server 2.12.0
- Nakama Cocos2d API 2.3.0
The question is: how can I configure the room’s name (or label) when I create a new match?
These are the features I’m trying to do in my game:
- A player could create a new room/match with a custom name.
- A player could see all the rooms created currently in the server, and what players are playing in each room.
For make the second point, I’m using the method listMatches
:
/**
* Fetch a list of matches active on the server.
*
* @param session The session of the user.
* @param min_size The minimum number of match participants.
* @param max_size The maximum number of match participants.
* @param limit The number of matches to list.
* @param label The label to filter the match list on.
* @param authoritative <c>true</c> to include authoritative matches.
*/
virtual void listMatches(
NSessionPtr session,
const opt::optional<int32_t>& min_size = opt::nullopt,
const opt::optional<int32_t>& max_size = opt::nullopt,
const opt::optional<int32_t>& limit = opt::nullopt,
const opt::optional<std::string>& label = opt::nullopt,
const opt::optional<bool>& authoritative = opt::nullopt,
std::function<void(NMatchListPtr)> successCallback = nullptr,
ErrorCallback errorCallback = nullptr
) = 0;
It works.
About the first point, I don’t know how can I configure a room’s name/label, because I can’t send the name in the method createMatch
:
/**
* Create a multiplayer match on the server.
*/
virtual void createMatch(
std::function<void(const NMatch&)> successCallback,
RtErrorCallback errorCallback = nullptr
) = 0;
Also, I can’t edit the label in the callback:
auto successCallback = [](const NMatch& match)
{
//match.label here is empty and I can't edit it, it's a const.
};
So, the problem is, when I use listMatches
, all matches/rooms names are empty (""). So I can’t make a window showing a matchs list in the server (I don’t want to show matchs ids, I would like to do it friendly… showing match’s names).
Maybe there’s a solution from the server side: https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/
But I want to make it from the client side.
Are there any chance to make an improve in the method createMatch
? It would be nice if I can send the label
. I’m not asking for a huge feature… it’s very simple. I just want to show all the current matchs lists with their names (friendly).
Is very common in a real-time multiplayer game, create a room with a custom name and see the currents rooms lists. So for example, I can create the room “tranthor game!” and I tell my friend to connect to my room called “tranthor game!”.