Hi everyone!
I'm trying to implement skill-based matchmaking for my game by using Photon Networking + PlayFab. It's almost working but I'm stuck at the very end. Here is what I did so far:
1) My PlayFab Title is integrated with Photon plugin.
2) Newly registered players get default PlayerStatistic "Rank" via CloudScript. (Thanks to this thread)
handlers.setDefaultRankForNewPlayer = function(args, context) { var updateStatistics = server.UpdatePlayerStatistics({ PlayFabId: currentPlayerId, Statistics: [{ "StatisticName": "Rank", "Value": 1500 }] }); }
3) When a player logs into my game I'm fetching his current Rank and PlayFabID from PlayFab.
4) When new Photon rooms are created, I'm assigning CustomRoomProperty "RoomRank" to those rooms with the value of the current rank of the Player that created this room.
5) When players are searching for existing rooms, I'm comparing their current rank to the RoomRank and limit the room search filter accordingly. (Thanks to this video)
6) When the room is full (in my case only 2 people: player and enemy) a match begins.
7) When the match ends I need to update each player's rank in PlayFab. I've written a CloudScript function, that takes PlayFabID's of both players and the result of the match (win/loose/draw). It then calculates the new rank for each player and updates each player's statistic accordingly.
The problem: from where shall I call the CloudScript function from step 7 ?
One of the clients could issue ExecuteCloudScript request, but I dont want the clients to be responsible for this call, because a) it's not their responsibility and b) if the client's internet connection fails then the other player will never get his rank updated.
I could use a webhook that updates both player's ranking when a room is closed. But this weebhook needs to know the result of the game and both player's IDs and I dont know how to get those prameters to my webhook.
I could actually store both player's IDs and the game result in Photon's CustomRoomProperties but I'm not sure how to access it from a webhook.
I really need help with this!
Thank you!