I’m using Nakama C++ with Unreal Engine.
I’ve got it working up to Authentication, joining pools, and authentication. However when I try to join the match I get an “Invalid match id” error.
If I debug I notice that the matchId is an empty string. The debug printout:
matchId = ""
ticket = "6debf08e-af61-4826-8271-c902eda8579e"
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NjI2NDI1MjIsIm1pZCI6IjRmMTg3ODM0LTBkNmMtNDU0OC05OTE1LTcyZmI1MzAyOTU0Ni4ifQ.HDEZbHaHcMmimRaoO2rN2bkhG25fimNQEJuT4sGSD6g"
Here is the code:
void UNetworkManager::FindMatch() {
int32_t minPlayers = 2;
int32_t maxPlayers = 2;
std::string query = "*";
auto onJoinedPool = [](const NMatchmakerTicket& ticket) {
UE_LOG(LogTemp, Warning, TEXT("Nakama: Joined Pool"));
};
RTNetworkClient->addMatchmaker(minPlayers, maxPlayers, query, {}, {}, onJoinedPool);
NetworkListener.setMatchmakerMatchedCallback([this](NMatchmakerMatchedPtr matched)
{
UE_LOG(LogTemp, Warning, TEXT("Nakama: Match Found"));
JoinMatch(matched->token);
});
}
void UNetworkManager::JoinMatch(string matchId)
{
RTNetworkClient->joinMatch(matchId, [this](const NMatch& match)
{
UE_LOG(LogTemp, Warning, TEXT("Nakama: Joining Match"));
std::vector<FNetworkUser> users(match.presences.size());
std::transform(match.presences.begin(), match.presences.end(), users.begin(), [](NUserPresence user) {
return FNetworkUser { user.username.c_str(), user.userId.c_str() };
});
if (users.size() > 0)
{
TArray<FNetworkUser> usersTArr;
usersTArr.Append(&users[0], users.size());
FNetworkUser currentUser{ match.self.username.c_str(), match.self.userId.c_str() };
OnMatchFound(FMatchInfo{ match.matchId.c_str(), currentUser, usersTArr });
}
});
}
If it helps, what I’m trying to do is match any two players in a 1v1 realtime game. I thought matchmaking could do this for me without having to have a client call createMatch