How to do server side custom matchmaking

I am working on a turn based multiplayer game where i was using PhotonNetwork.JoinRandomRoom() up until now. But now i need to add some custom matchmaking features such as, if i have played a match with a player i cannot play next four matches with this same player etc. So i want my matchmaking to happen on my backend server if possible.
Thanks in advance for your answers

Best Answers

  • jeanfabre
    jeanfabre mod
    Answer ✓
    Hi,

    To make server side matchmaking, you will need a custom dedicated server and create a plugin for this, we also provide an enterprise plan if you want to benefit from our cloud distribution yet want a dedicated server setup, including custom plugins.

    https://www.photonengine.com/en-US/Server/pricing

    https://www.photonengine.com/en-US/PUN/pricing

    Bye,

    Jean

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2020 Answer ✓
    Hi @arya_harshwardhan,

    Thank you for choosing Photon!

    I want to add updates and clarifications:

    The plugins we have now in the Photon Server Plugins SDK are GameServer plugins which intervene only when the room is created so they can't be used for matchmaking without adding something else.

    There could be some new addition regarding this in Photon Server v5 for SQL lobbies.
    I will double check this and get back to you.

    Otherwise, there may be other custom options for you if you want this but this requires special services/contract.
    If you want to go this way, send an email to developer@photonengine.com to request this.

    But what you could do is to make matchmaking external to Photon, via HTTP based web service maybe, and then use Photon just to create and join rooms (or one call JoinOrCreate).
    Such matchmaking service could make use of (combined with) Photon's "native HTTP modules" (Custom Authentication / WebRPCs / WebHooks) or even a custom plugin to report rooms availability to your web service.
    Things to consider: Region, AppVersion, AppId, UserId, RoomName/GameId, Auth Cookie, URL tags, etc.

    Another options is to modify LoadBalancing server application, MasterServer specifically, the matchmaking part. This option is for self-hosted only of course.
    add some custom matchmaking features such as, if i have played a match with a player i cannot play next four matches with this same player etc.
    Not nice but a "cheap" option to mention (not tested and not recommended):
    There is also the option to do this only using client only but still you need a way to save the list of the players you encountered in the last four rooms you joined. If you're happy to do it locally you could:
    - keep calling JoinRandomRoom until a room that does not have a player we encountered in the last previous rooms is there. You could change MatchmakingMode here if the lobby type is not SQL Lobby.
    - call JoinRandomRoom with a custom filter (userIDs of players to skip) to avoid all these players and expose the room's players' UserIDs in the lobby (not recommended).
    - [to avoid rejoining old rooms but you still need to avoid rooms that have users you encountered in the last 4 rooms] create rooms with PlayerTTL == -1, leave rooms with LeaveRoom(true); this way the actor remains in the room inactive and can't be matched in a previously joined room. you need to keep same UserID though.

Answers

  • Can anybody help me out here give me something......anything, in a bit of pickle right now. Urgent help required please.
  • jeanfabre
    jeanfabre mod
    Answer ✓
    Hi,

    To make server side matchmaking, you will need a custom dedicated server and create a plugin for this, we also provide an enterprise plan if you want to benefit from our cloud distribution yet want a dedicated server setup, including custom plugins.

    https://www.photonengine.com/en-US/Server/pricing

    https://www.photonengine.com/en-US/PUN/pricing

    Bye,

    Jean

  • It would be very generous of you @jeanfabre , if you can provide me with an example plugin where there is some kind of custom matchmaking already implemented as I have read the plugins documentation and i am unable to figure out how i would implement the same using a custom plugin. And also i was thinking of going for the enterprise cloud if i am able to do the custom matchmaking
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2020 Answer ✓
    Hi @arya_harshwardhan,

    Thank you for choosing Photon!

    I want to add updates and clarifications:

    The plugins we have now in the Photon Server Plugins SDK are GameServer plugins which intervene only when the room is created so they can't be used for matchmaking without adding something else.

    There could be some new addition regarding this in Photon Server v5 for SQL lobbies.
    I will double check this and get back to you.

    Otherwise, there may be other custom options for you if you want this but this requires special services/contract.
    If you want to go this way, send an email to developer@photonengine.com to request this.

    But what you could do is to make matchmaking external to Photon, via HTTP based web service maybe, and then use Photon just to create and join rooms (or one call JoinOrCreate).
    Such matchmaking service could make use of (combined with) Photon's "native HTTP modules" (Custom Authentication / WebRPCs / WebHooks) or even a custom plugin to report rooms availability to your web service.
    Things to consider: Region, AppVersion, AppId, UserId, RoomName/GameId, Auth Cookie, URL tags, etc.

    Another options is to modify LoadBalancing server application, MasterServer specifically, the matchmaking part. This option is for self-hosted only of course.
    add some custom matchmaking features such as, if i have played a match with a player i cannot play next four matches with this same player etc.
    Not nice but a "cheap" option to mention (not tested and not recommended):
    There is also the option to do this only using client only but still you need a way to save the list of the players you encountered in the last four rooms you joined. If you're happy to do it locally you could:
    - keep calling JoinRandomRoom until a room that does not have a player we encountered in the last previous rooms is there. You could change MatchmakingMode here if the lobby type is not SQL Lobby.
    - call JoinRandomRoom with a custom filter (userIDs of players to skip) to avoid all these players and expose the room's players' UserIDs in the lobby (not recommended).
    - [to avoid rejoining old rooms but you still need to avoid rooms that have users you encountered in the last 4 rooms] create rooms with PlayerTTL == -1, leave rooms with LeaveRoom(true); this way the actor remains in the room inactive and can't be matched in a previously joined room. you need to keep same UserID though.