FChatMessage struct doesn't exist in Nakama Unreal plugin as it's shown in the party invitation example on documentation

  1. Versions: Unreal Engine 5.3, Nakama Unreal Plugin 2.9.4, Nakama Cloud Image heroiclabs/nakama-enterprise:3.22.0-r1-mc

Hey there, I’m trying to implement a basic party creation/invitation logic but the client library example on the docs doesn’t seem like matching with the source code.

On the documentation example to send a direct message that includes PartyID to send invitation is as following:

FChatMessage ChatMessage;
ChatMessage.Message = FString::Printf(TEXT("Hey %s, wanna join the party?"), *Friends.NakamaUsers[i].NakamaUser.Username);
ChatMessage.PartyId = CurrentParty.PartyId;

FString Json;
FJsonObjectConverter::UStructToJsonObjectString(ChatMessage, Json);

RealtimeClient->SendDirectMessage(Friends.NakamaUsers[i].NakamaUser.Id, Json, SendDirectMessageSuccessDelegate, SendDirectMessageErrorDelegate);

However FChatMessage struct doesn’t exist in the plugin. I realized that I was using an older version and updated to 2.10 but the struct still doesn’t seem like existing. When I try to use it, it’s referencing OnlineChatInterface’s FChatMessage struct. There is a FNakamaChatMessage struct which doesn’t have partyId property.

I tried sending a direct message by filling the content as {"partyId":"<myPartyID>"} manually and when send it I get {"cid":"5","error":{"code":3,"message":"Invalid channel identifier"}} as error. I tried using JoinChat before sending the message, which returns success, but doesn’t change the outcome.

So I’m a bit confused about how to send a party invite to a friend.

Thanks for this note. Copying @gabriel to help with the docs here.

Hey @MetaCan,
The FChatMessage struct is implemented earlier in the give here: Unreal - Heroic Labs Documentation

The documentation is written in a way of a full game example, so the sections can’t be looked at in isolation, as you can see in this case why.

Let me know if this solves your issue!

Thanks @DannyIsYog this explains my first question. I didn’t check the Chat section of the documentation, I was looking purely at party related stuff, that’s my bad. However it could have been nice if searching for that would reveal the section it’s being described on the documentation.
image

As for my second question, on the documentation sending direct message example is shown as below on sending party and match invitation sections

RealtimeClient->SendDirectMessage(Friends.NakamaUsers[i].NakamaUser.Id, Json, SendDirectMessageSuccessDelegate, SendDirectMessageErrorDelegate);

Which I believe indicating to send the ID of the user we want to send the message, as the parameter name UserID on UNakamaRealtimeClient::SendDirectMessage() function also indicates that. However that function internally calls UNakamaRealtimeClient::WriteChatMessage() which expects a ChannelID as first parameter but being fed with the UserID parameter.

In short, using UNakamaRealtimeClient::SendDirectMessage() with a user ID as the first parameter results with a real time error with message {"cid":"5", "error":{"code":3, "message":"Invalid channel identifier"}}.

I was able to tackle this issue by mapping successfully joined channels against their foreign user ID to a TMap<FString, FNakamaChannel> and do a lookup with friend’s UserID to get the FNakamaChannel.ChannelId whenever I would need to send a direct message.

I’d be happy if you can clear things out on if I’m missing an information on sending direct messages (chat section only shows UNakamaRealtimeClient::SendMessage() examples) or if there is a mismatch on the documentation