unique room Id


I'm changing my game netcode from Steam to Photon and I need a unique identifier to identify my rooms. Is there something in photon that can allow me to generate a unique id (uint64_t) ?


  • Kaiserludi
    Kaiserludi admin
    edited November 2019
    Hi @benjaml.

    If you don't set a room name yourself on creation, but just pass an empty string, then the server will assign one for you. This server assigned room name is a GUID.
    You could get a hash code of that GUID string through the C++ 11 standard library or boost hash function, but I am afraid that that hash would unlike the string from which it has been generated, not be guaranteed to be unique. We are planning to add a unique server-generated integer identifier for each room in the future exactly for this purpose. However this feature is not available yet.

    Currently you have the following options:
    a) On Photon Enterprise Cloud and with self-hosted Photon Server instances you can simply write a server side plugin that store a unique 64 bit integer value in the rooms properties on room creation.
    b) A solution that would also work with Photon Public and Premium Cloud, where no custom plugins are supported, is to write your own HTTP server that you host yourself and which can be asked for a unique integer ID by your client side code. This is necessary as you need some kind of authority that knows all IDs that are already taken to guarantee uniqueness with only 64bit (GUID / UUID algorithms are able to create a random number that is unlikely enough to match any number that has ever been previously used as unique ID by anyone for anything anywhere on the world / in the universe, but those numbers are far bigger than 64bit and cutting them down to 64bit would result in loosing their guaranteed uniqueness), hence a client-side only approach does not suffice.