Photon V2 -- PlayFab Webhooks

Options
I'm tearing my hair out trying to figure out how to convert this PlayFab-- Photon connection sample method from Photon V1 to V2. Original document: https://api.playfab.com/docs/tutorials/landing-tournaments/photon-unity

In the V1 sample, RaiseEventOptions had a "ForwardToWebhook" option to tell the event handler to trigger a webhook, however I can't find information on how to convert it to the new Photon V2 Unity methods.

Here is the original custom event method (called when a button is pressed with the player logged into a room) :
    // Example code which raises custom room event, then sets custom room property
    private void ExecuteExample()
    {
        // Raise custom room event
        var data = new Dictionary<string, object>() { { "Hello", "World" } };
        var result = PhotonNetwork.RaiseEvent(15, data, true, new RaiseEventOptions()
        {
            ForwardToWebhook = true,
        });
        LogMessage("New Room Event Post: " + result);

        // Set custom room property
        var properties = new ExitGames.Client.Photon.Hashtable() { { "CustomProperty", "It's Value" } };
        var expectedProperties = new ExitGames.Client.Photon.Hashtable();
        PhotonNetwork.room.SetCustomProperties(properties, expectedProperties, true);
        LogMessage("New Room Properties Set");
    }

If I update it to clear the errors, I end up with the following (below), which obviously doesn't know to push to playfab in the current state -- anyone know how I can update it to push properly?
    // Example code which raises custom room event, then sets custom room property
    private void ExecuteExample()
    {

        // Raise custom room event
        var data = new Dictionary<string, object>() { { "Hello", "World" } };
        var result = PhotonNetwork.RaiseEvent(15, data, new RaiseEventOptions(), new SendOptions());
        LogMessage("New Room Event Post: " + result);

        // Set custom room property
        var properties = new ExitGames.Client.Photon.Hashtable() { { "CustomProperty", "It's Value" } };
        var expectedProperties = new ExitGames.Client.Photon.Hashtable();
        PhotonNetwork.CurrentRoom.SetCustomProperties(properties, expectedProperties);
        LogMessage("New Room Properties Set");
    }

Thank you in advance!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2018
    Options
    Hi @Sxraxis,

    Thank you for choosing Photon!

    First I want to clarify something:
    Photon is the brand/name of a family of products.
    PUN or Photon Unity Networking is one of them.
    We recently released PUN2 (version 2) and not Photon 2.

    Here is how to use web flags in general, HttpForward in particular, in PUN2:
    PhotonNetwork.CurrentRoom.SetCustomProperties(properties, expectedProperties, new WebFlags(WebFlags.HttpForwardConst));
    The same applies to all methods that support web flags. e.g. RaiseEvent.
  • Sxraxis
    Options
    That did the trick, thank you!

    You are correct, I am referring to PUN2. Here is the how I modified the code with the offered corrections to successfully trigger the events in PlayFab (per the tutorial modified cloudscripts) -- I knew it would be something small. ;)
        // Example code which raises custom room event, then sets custom room property
        private void ExecuteExample()
        {
            // Raise custom room event
            var flags = new WebFlags(WebFlags.HttpForwardConst);
            var data = new Dictionary<string, object>() { { "Hello", "World" } };
            var result = PhotonNetwork.RaiseEvent(15, data, 
                new RaiseEventOptions() { Flags = flags },
                new SendOptions());
            LogMessage("New Room Event Post: " + result);
    
            // Set custom room property
            var properties = new ExitGames.Client.Photon.Hashtable() {
                {"CustomProperty", "It's Value"}};
            var expectedProperties = new ExitGames.Client.Photon.Hashtable();
            PhotonNetwork.CurrentRoom.SetCustomProperties(properties, expectedProperties, flags);
            LogMessage("New Room Properties Set");
        }