Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Integrating Corona, Playfab and Photon
Started by renaut.el Mar 14 2019 04:03 AM

No replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

renaut.el

[GLOBAL: userInfoPane.html]
renaut.el
  • Observer

  • 1 posts
  • Corona SDK

Hi guys,

I am currently trying to create a simple turn by turn multiplayer game (slow speed).

The game has been developed in mono player mode with Corona.

I have decided to use Playfab to manage my players and photon for the matchmaking/room management.

Unfortunately there are very very few examples of code with these three services working together.

 

My code works fine up to know, I can login to playfab with CustomId and generate a call to get a photonToken, I receive the photon token, but then I don't know what to do with it.

My understanding is that I can now call Cloudscripts on the playfab side to OpenRoom. My Webhooks are set up and ready for that but I have no clue how to write the scripts correctly and can't find any examples. Anybody could help me on that ?

 

Thanks, philippe

local loginRequest = {
        -- https://api.playfab.com/documentation/Client/method/LoginWithCustomID
        CustomId = "Test",
        CreateAccount = true
}

local PhotonAuthenticationToken={
    PhotonApplicationId = "my-photon-id-is-here"
}

local PlayFabId=""
local function AuthenticateWithPhoton(result)
  print("Photon token acquired: "..result.PhotonCustomAuthenticationToken.."  Authentication complete.");


local customAuth={}
        --We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.username=PlayFabId
        --We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.token=result.PhotonCustomAuthenticationToken

end

local function RequestPhotonToken (result)
  print("LOGIN :"..result.PlayFabId)
  print("PlayFab authenticated. Requesting photon token...");
  PlayFabId=result.PlayFabId
  PlayFabClientApi.GetPhotonAuthenticationToken(PhotonAuthenticationToken, AuthenticateWithPhoton, function(error) print("Authenticate Photon went wrong") end);
end

PlayFabClientApi.LoginWithCustomID(loginRequest,
        RequestPhotonToken,
        function(error) print("Something went wrong with your first API call.\nHere's some debug information:\n" .. error.errorMessage) end
    )





[topic_controls]
[/topic_controls]