How do I add metadata to presences?

Hi. Here’s what I need:

> Users start a WebRTC RTCpeer connection in Unity. Now, I have access to a SDP variable that I want to share among the rest of the users.
> Users join a match
> The matchJoin will update the "state: sdps { } " by adding the presences SDPs. < **This is where I'm stuck, as I can't find a way for the clients to share their stuff to the server.**

So, is there a way to have metadata inside a presence? Or any way for the client to send data on the matchJoin function?

I’d do this by just sending a message from the client and then using matchLoop on the server, but it feels dirty and more error-prone than just handling this when a client joins the match.

Hi, @uwu!

Nakama’s Presence has a few metadata fields but they are not meant for this type of usage. This feature looks similar to chat feature but it could be done using OpCode like the one on the Fish Game tutorial.

Hope this helps.

Cheers,
Caetano

Hi.

I don’t understand how OpCodes would be useful in this situation, as they’re just a way to organizing the received messages in code.

What I want is to send a string to the server the exact moment the user joins the match, and add it to the match state by using the matchJoin function on the Typescript server.

I’m just wondering if there’s a way to do so. If it’s not possible, I can just use the SendMatchState function from the client or call a RPC function.
But I feel like I’d need to code way more stuff to handle it and possible errors, since it may be possible that the player ends up joining the match but not sending their SDP for some reason (Example: They join the match and instantly disconnect. Or they join the match but they’re laggy so sending another message takes a while. Or if another player connects, requests the players SDPs, but they’re not ready yet). Meanwhile, by using the matchJoin function with the SDP ready would mean that nothing could go wrong since the SDP string is already on the server the moment they join.