Custom matchId for private lobby/room?

I am trying to create a private room/lobby for a board game(like tic tac toe) where you play against your friends. So far, I have been able to create the match and join them by following the documentation.

However, the match id it generates is a very long string. Even if your friend is beside you, you will need to send that match id with some social medias. I want to convert that “match id” into some simple digits(probably of 5-6 digit) that can by typed manually. How can I implement this feature?

I tried to create a global dictionary variable holding some random numbers that point to that “match id” and some rpc function to retrieve that “match id” from that random number. But global variables are not supported in typescript.

Any pointers on how can I implement this feature?

Thank you


One way to achieve this is to create a server-side RPC function which takes the long match_id as an input and returns some abbreviated match code using a storage collection with 2 columns: match_code, match_id. Client would call this function when match-making: this RPC would generate a new match_code and insert it in the collection associated with the internal match_id, then return the match_code to the client that started the match.

On the match join, a client would call another RPC with reverse logic: take match_code as input and return the long match_id to the client to pass to MatchJoin.

You may be able to do it all in one RPC and some details may differ depending on whether you are planning to have authoritative matches or not.

Hope this works for you,

Also, in case you are using .NET/ Unity client, more recent versions of Nakama now support creating matches by specifying a match/room name.