- Versions: Nakama heroiclabs/nakama-enterprise:3.22.0-r3-mc, NakamaUnreal v2.10.0
I’ve bound a function to UNakamaRealtimeClient::PartyMatchmakerTicketReceived
which gets triggered for all players in the party. However, only party leader has valid data, non party leader players get empty strings for both FNakamaPartyMatchmakerTicket::PartyId
and FNakamaPartyMatchmakerTicket::Ticket
.
I’ve tracked down the issue to the FNakamaPartyMatchmakerTicket::FNakamaPartyMatchmakerTicket(const FString& JsonString)
constructor. Party leader and non leader members received different JSON data in here.
PartyMember = {"party_id": "812cdfa5-0b94-4a53-bc59-44d01901059b.nakama-0","ticket": "ee72e4b5-8472-4085-b7e5-e1231b99604d"}
PartyLeader = {"cid":"7", "party_matchmaker_ticket":{"party_id":"812cdfa5-0b94-4a53-bc59-44d01901059b.nakama-0", "ticket":"ee72e4b5-8472-4085-b7e5-e1231b99604d"}}
Since constructor checks for the existence of “party_matchmaker_ticket”, it’s failing to parse the data for non party leader members. Changing the constructor from
FNakamaPartyMatchmakerTicket::FNakamaPartyMatchmakerTicket(const FString& JsonString)
{
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(JsonString);
if (!FJsonSerializer::Deserialize(JsonReader, JsonObject))
{
return;
}
TSharedPtr<FJsonObject> PartyTicketObject = JsonObject->GetObjectField(TEXT("party_matchmaker_ticket"));
if (!PartyTicketObject.IsValid())
{
return;
}
PartyTicketObject->TryGetStringField(TEXT("ticket"), Ticket);
PartyTicketObject->TryGetStringField(TEXT("party_id"), PartyId);
}
to
FNakamaPartyMatchmakerTicket::FNakamaPartyMatchmakerTicket(const FString& JsonString)
{
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(JsonString);
if (!FJsonSerializer::Deserialize(JsonReader, JsonObject))
{
return;
}
if (JsonObject->HasField(TEXT("party_matchmaker_ticket")))
{
TSharedPtr<FJsonObject> PartyTicketObject = JsonObject->GetObjectField(TEXT("party_matchmaker_ticket"));
if (!PartyTicketObject.IsValid())
{
return;
}
PartyTicketObject->TryGetStringField(TEXT("ticket"), Ticket);
PartyTicketObject->TryGetStringField(TEXT("party_id"), PartyId);
}
else
{
JsonObject->TryGetStringField(TEXT("ticket"), Ticket);
JsonObject->TryGetStringField(TEXT("party_id"), PartyId);
}
}
apparently fixes the problem for me momentarily.