question

contact-7 avatar image
contact-7 asked

How to create photon room ?

Hello there,

I'm trying to connect user to photon with playfab connection and join or create a room but I've an issue: "JoinOrCreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster."

My C# code:

    public string PlayFabAppId = "My_TitleID";

    string PlayFabId;



    // Use this for initialization

    void Start ()

    {

        PlayFabSettings.TitleId = PlayFabAppId;

        PlayFabAndPhotonLogin ();

    }



    void PlayFabAndPhotonLogin()

    {

        var request = new LoginWithPlayFabRequest

        {

            TitleId = PlayFabAppId,

            Username = "My_UserName",

            Password = "My_PassWord"

        };

        PlayFabClientAPI.LoginWithPlayFab(request, (success) => 

        {

            PlayFabId = success.PlayFabId;



            Debug.Log("Login to Playfab: " + PlayFabId);

            GetPhotonToken();

        },

        (error) => 

        {

            Debug.LogError("Login error: " + error.GenerateErrorReport());

        });

    }



    void GetPhotonToken()

    {

        GetPhotonAuthenticationTokenRequest request = new GetPhotonAuthenticationTokenRequest();

        request.PhotonApplicationId = PhotonNetwork.PhotonServerSettings.AppID.Trim();

        Debug.Log("Getting auth token..");

        PlayFabClientAPI.GetPhotonAuthenticationToken(request, (success) => {

            string photonToken = success.PhotonCustomAuthenticationToken;

            Debug.Log(System.String.Format("Auth token success: {0}", photonToken));

            PhotonNetwork.AuthValues = new AuthenticationValues();

            PhotonNetwork.AuthValues.AuthType = CustomAuthenticationType.Custom;

            PhotonNetwork.AuthValues.AddAuthParameter("username", PlayFabId);    // expected by PlayFab custom auth service

            PhotonNetwork.AuthValues.AddAuthParameter("token", photonToken);   // expected by PlayFab custom auth service

            

            PhotonNetwork.ConnectUsingSettings(PhotonNetwork.gameVersion);   //Connect to the Photon Master server like we would normally do 



            RoomOptions roomOptions = new RoomOptions();

            roomOptions.IsVisible = false;

            roomOptions.MaxPlayers = 4;

            PhotonNetwork.JoinOrCreateRoom("testRoom", roomOptions, TypedLobby.Default);

        }, (error) => {

            Debug.Log(error.ErrorMessage);

        });

    }

}

Thanks,

Sblouf

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

For questions on using the Photon SDK API calls, you'll need to work with the Exit Games team, as they are the folks behind Photon Cloud. We partnered with them to be able to offer a tight integration with them in PlayFab, but we cannot support their product directly. You can find them on their forums, here: http://forum.photonengine.com/.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

contact-7 avatar image contact-7 commented ·

Ok, thanks @Brendan I'll go see there.

I've another question:

How to add photon server in server tab on playfab ?

I've read the doc here: Using Photon with PlayFab but it doesn't look up to date...

Thanks,

Sblouf

0 Likes 0 ·
brendan avatar image brendan contact-7 commented ·

We're in the process of reviewing and updating our online docs now, in fact.

But the Server Tab is not related to Photon - it is for info on any custom game servers you're running in our service (https://api.playfab.com/docs/tutorials/landing-tournaments/custom-game-servers).

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.