How to pass data threw server ?

Hello everyone !

Here is my scenario :
Some players want to play my multiplayer game (yeah !). When a player creates a server, he chooses a nickname. When the others want to join the opened game, they choose a nickname too. How can I be sure of the unicity of the nicknames ?

In my opinion, HostData.comment could be an option. Like, when a player has chosen a name, I put it in the comment of the hostdata, when an other one wants to join, I check the comment and if it contains the nickname, I stop the second player and tell him to choose an other one. The trick would be to concatenate all the nicknames in the comment and separate them with a special key (to encode and decode it easily) which could not be in a nickname.

So here are my questions :

first : is my idea would be an option ?

second : is there an other and easier method to do what I want ?

Thanks !

EDIT : up .

I imagine since you have a multiplayer game that you have some kind of List filled with all players - in my mind it would be simpler to have a for loop that iterates through your list comparing the new nickname with existing ones. I’m not sure which method is more efficient, but both are definitely possible.

I feel like I’m not answering your question fully though, your title and body are asking different things.