question

John Peterson avatar image
John Peterson asked

Photon WebHooks not triggered?

Dear PlayFab community,

I have the same problem as this thread.

However, none of the resolutions in the thread seem to apply to me. As far as I can tell, I've got everything configured properly on both ends, but none of my WebHooks are getting triggered.

I'm following the Photon PlayFab integration instructions.

Here are my Photon settings in Unity:

And a successful connection is made with the following C# code:

private static string Version = "0.1";

private void ConnectPhoton(string PlayFabId, string token /*from PlayFabClientAPI.GetPhotonAuthenticationToken()*/)
{
	// Set up the Photon authentication aspects.
	AuthenticationValues authenticationValues = new AuthenticationValues();
	authenticationValues.AuthType = CustomAuthenticationType.Custom;
	authenticationValues.AddAuthParameter("username", PlayFabId);
	authenticationValues.AddAuthParameter("token",    token);

	PhotonNetwork.AuthValues = authenticationValues;

	// Connect to Photon.
	PhotonNetwork.ConnectUsingSettings(Version);
}

Photon AppID: f3416d52-4d66-4ac0-9d8a-75b545a8925d

(Note that the BaseUrl has the SECRET_KEY appended and is not shown here. I have confirmed that this is the same value that appears in the PlayFab Photon Add-On module.)

PlayFab (AppID: 44b1) CloudScript:

interface IPhotonResult
{
   ResultCode: number,
   Message:    string
}
const photonSuccess: IPhotonResult = { ResultCode: 0, Message: 'Success' };

var RoomCreated = function(args: any, context?: IPlayFabContext): IPhotonResult
{
   Log.Debug("photon_room_created", JSON.stringify(args));
   WritePlayerEvent("photon_room_created", args);
   return photonSuccess;
}
var RoomClosed = function(args: any, context?: IPlayFabContext): IPhotonResult
{
   WritePlayerEvent("photon_room_closed", args);
   return photonSuccess;
}
var RoomJoined = function(args: any, context?: IPlayFabContext): IPhotonResult
{
   Log.Debug("photon_room_joined", JSON.stringify(args));
   WritePlayerEvent("photon_room_joined", args);
   return photonSuccess;
}
var RoomLeft = function(args: any, context?: IPlayFabContext): IPhotonResult
{
   WritePlayerEvent("photon_room_left", args);
   return photonSuccess;
}
var RoomEventRaised = function(args: any, context?: IPlayFabContext): IPhotonResult
{
   WritePlayerEvent("photon_room_event_raised", args);
   return photonSuccess;
}
var RoomPropertyUpdated = function(args: any, context?: IPlayFabContext): IPhotonResult
{
   WritePlayerEvent("photon_room_property_updated", args);
   return photonSuccess;
}
var WebRPCTest = function(args: any, context?: IPlayFabContext): IPhotonResult
{
   WritePlayerEvent("photon_webrpc_test", args);
   return photonSuccess;
}

handlers["roomCreated"]         = RoomCreated;
handlers["roomClosed"]          = RoomClosed;
handlers["roomJoined"]          = RoomJoined;
handlers["roomLeft"]            = RoomLeft;
handlers["roomEventRaised"]     = RoomEventRaised;
handlers["roomPropertyUpdated"] = RoomPropertyUpdated;
handlers["webRPCTest"]          = WebRPCTest;

Thoughts?

photonwebhooks
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

Actually, the logs show that the handlers are being called. The problem is that your WritePlayerEvent calls are invalid, and so cause the handlers to error out. The base Cloud Script example (Revision 1 in all new titles) shows some examples of how to make a Server API call.

4 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.

John Peterson avatar image John Peterson commented ·

Ahhh...thanks, I see that now. I thought that WritePlayerEvent was so simple that there wasn't any way for me to screw it up. ;-)

Is there a way for me to see the logs for those kinds of calls? That would have helped me to debug this issue.

0 Likes 0 ·
brendan avatar image brendan ♦♦ John Peterson commented ·

Yes, use try/catch for all Server API calls, and log the error you get on any catch.

0 Likes 0 ·
John Peterson avatar image John Peterson commented ·
@Brendan, I have updated my code, and I'm getting the photon_room_left event. But I'm *not* getting the photon_room_created or photon_room_joined WebHooks (they're identical to the photon_room_left).

How can I debug this further? It seems like I don't have access to these internal logs...

0 Likes 0 ·
brendan avatar image brendan ♦♦ John Peterson commented ·

I've responded in the other thread you started on this - here, for the sake of others: https://community.playfab.com/questions/20786/photon-webhooks-not-triggered-redux.html

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.