Generating Unique Static Codes for Each Session in Unity Netcode with Unity Relay

Hello everyone,

I am looking to generate a unique static code for each session that we create in Unity Netcode with Unity Relay. I would appreciate any insights, tips, or examples on how to achieve this.

Thank you!

Like +1 on a global counter?

Or the host creating new Guid() ?

You could just use the relay code itself, rather its hash code. At least for the currently active sessions that code should be unique per session.

I understand what you’re saying, and I wanted to clarify: what I was asking is if it’s possible to have a session with the same code that can be used over multiple days. For example, if the host leaves the session, would it still be possible to recover and reuse that same session code to reconnect ? Or is the session and its code permanently tied to the host, requiring a new code once the session ends ?

No. The services creates a new code every time a host requests a code. If the host leaves the session the code will become invalid.

Thank you very much for your answer. I think it could be a cool feature to have the choice to create unique codes for private sessions, ensuring that we know we own them and that we could join them at any moment we want (even if the host leaves).

Hmmm I think you could implement that with the other cloud services. Cloud Save at a minimum to list current sessions by name - I think that’s possible. If not, you may have to use Cloud Code on top to be less restricted on the API side.

Idea being that host creates a session and gives it a (unique) name. Other players can find the session by name. Several games implement this, it’s barebones but isn’t much work and players understand it.

Oh okay, I will try to do that thank you very much for your help and time.