Custom room name from my backend
Options
Hi,
We are using Photon in our multiplayer game.
Our game is designed to have a 4 digit room name.
One approach is :
1. generate a 4 digit number
2. Call CreateRoom()
3. OnPhotonCreateRoomFailed() repeat step one
We know that this approach is not really scalable(we have only 4 digits) due to possible collisions.
Are our concerns valid?
Is there any way to use our backend for issuing room names?
We are using Photon in our multiplayer game.
Our game is designed to have a 4 digit room name.
One approach is :
1. generate a 4 digit number
2. Call CreateRoom()
3. OnPhotonCreateRoomFailed() repeat step one
We know that this approach is not really scalable(we have only 4 digits) due to possible collisions.
Are our concerns valid?
Is there any way to use our backend for issuing room names?
0
Comments
-
Hi @Oddreams,
Thank you for choosing Photon!
4 digits mean: 10000 possible combinations (0000-9999) or 9000 (no zero to the left: 1000-9999).
First why do you have such a hard constraint? why set your own room names and not let the server generate GUIDs? then why 4 characters only? and why digits only?
Otherwise your approach can be improved by limiting collision if your generated 4 digit number has some factors/seeds like timestamp or UserId or some client hardware Id etc.Is there any way to use our backend for issuing room names?0 -
Hi @JohnTubeFirst why do you have such a hard constraint? why set your own room names and not let the server generate GUIDs? then why 4 characters only? and why digits only?
We implemented webhooks approach and it was very easy when persistent is true because the game was block till it got the response from our server.
Here it is the implementation:
1. in webhook config both SendSync and Persistent are true,
2. host player creates a room and let photon to assign its name.
3. photon synchronously send the webhook to backend and wait for response
4. our backend issues a random code and stores code, game id and region
5. when OnJoinedRoom is called we make a request to our backend with the photon room name to get our code
6. on room close we update our database and release the issued code
Please if you see any problem with our logic let me know.1 -
Hi @Oddreams,
very nice.
I love it.
in step 1 you mean "AsyncJoin" not "SendSync".
you could save the code as a room property (from the client as it's tricky to inject it in the room state using webhooks), this way you don't need to fetch it from you web server in step 5 when room is joined but you already have it as a room property.
step 4, I would maybe save more info to be safe (AppId, AppVersion, creator UserId) maybe you decide to change those later?
step 6, release code only when PathClose, Type=="Close" and not "Save".0 -
Hi @JohnTube
Thank you for your feedback.
Actually for now we are are using this just like a room finder based on a custom property, code in our case.
Regarding step one we have AsyncJoin false and SendSync true.
At last step we thought that close and save are done in one http request.
In my testing I do not see 2 http request one for save and one for close. Please confirm that?
In case of PathCreate we check type and for load we return result code not 0 as we do not support saving state.0 -
Hi @Oddreams,Regarding step one we have AsyncJoin false and SendSync true.At last step we thought that close and save are done in one http request.
In my testing I do not see 2 http request one for save and one for close. Please confirm that?0