how to auto match player?

edited March 2011 in Photon Server
hi, I'm new to photon. What I should do to make Photon server auto match player for my game?

I just try Photon Realtime Demo and found all players will join the same game in that. I just want similar feature, but in my case, I want 2 players in one game. If one more player comes, he may need to wait for another available player.

I don't know it is a server side or client side config problem. Please give me some hints.


  • Tobias
    Server side, the Realtime Demo uses the Lite application. That allows the clients to create and join any room dynamically without any further server side rules. The client names the room to join and the server will make that possible.

    You can expose these rules to achieve a basic "random matchmaking", purely done by the clients:
    • When a player searches for an opponent, make her join a certain room. Example: "matchme"
    • Make the player/client wait in that room until an event join from someone else arrives (everytime 2 players are in the room, they will leave it for playing a match)
    • Each client that joins the room triggers an event join, telling the newest player's actorNumber and the list of actornumbers currently in use in that room ("matchme")
    • The client which waited until a second client arrived generates a unique room name. Say "username"+timestamp or GUID.toString().
    • The waiting client uses OpRaiseEvent() with a list of target actorNumbers to send and "invitation". Use the actorNumber from event join from the second/new player in room "matchme" here and send the unique room name.
    • Make both players join the new room and play there

    If you want to make sure that everything works when more than 1 player joins the match room "matchme" at any time, you can use the join-event's actorNumber list to get pairs of players together.

    Of course, you could also implement a server-side matchmaking logic and let the server keep a list of players that want to be matched and then put them into a room when 2 players are available.