question

Hamza Lazaar avatar image
Hamza Lazaar asked

CloudScript Photon webhooks/webRPCs documentation and samples

I think the documentation for Photon webhooks and webRPC handlers and the basic samples given in the CloudScript revision 1 should be updated:

1. Unlike the comment on top of the respective handler (which is maybe due to copy/paste) currentPlayerId is available for RoomPropertyUpdated. It takes the value of args.UserId which is the UserId of the actor who updated the room or player properties.

2. It does not make sense to use log.Debug inside webhooks handlers. Instead you should use custom PlayStream events (a luxury early PlayFab users did not have :)).

3. In RoomEventRaised the right way to know event type is via args.EvCode which is the event code which should be between 0 and 200 for custom user events. So what is shown in the CloudScript sample is not a best practice or recommended as you use an extra field in the data to specify the event type. This may have been relevant in early stages of webhooks but not applicable anymore.

4. GetGameList is an example of webRPC and not a built in feature of Photon not PlayFab. This should be clearly documented as users tend to get confused about this.

5. An example of WebRPC is welcome to let customers know that hey can call any custom handler from Photon directly.

6. Default return type of webhooks handlers (in case of success or exception) should documented. IMO RoomCreated should not return State:"" on behalf of the user.

7. Webhooks settings values (HasErrorInfo, IsPersistent) could be mentioned for those who look for that info.

handlers.RoomCreated = function (args) 
{
    server.WritePlayerEvent(
        {
            PlayFabId: currentPlayerId,
            EventName: "photon_room_created",
            Timestamp: new Date(),
            Body: args
        }
    );
};


handlers.RoomJoined = function (args) 
{
    server.WritePlayerEvent(
        {
            PlayFabId: currentPlayerId,
            EventName: "photon_player_joined",
            Timestamp: new Date(),
            Body: args
        }
    );
};


handlers.RoomLeft = function (args) 
{
    server.WritePlayerEvent(
        {
            PlayFabId: currentPlayerId,
            EventName: "photon_player_left",
            Timestamp: new Date(),
            Body: args
        }
    );
};


handlers.RoomClosed = function (args) 
{
    server.WriteTitleEvent(
        {
            EventName: "photon_room_closed",
            Timestamp: new Date(),
            Body: args
        }
    );
};


handlers.RoomPropertyUpdated = function (args) 
{
    server.WritePlayerEvent(
        {
            PlayFabId: currentPlayerId,
            EventName: "photon_property_updated",
            Timestamp: new Date(),
            Body: args
        }
    );
};


handlers.RoomEventRaised = function (args) 
{
    server.WritePlayerEvent(
        {
            PlayFabId: currentPlayerId,
            EventName: "photon_event_raised",
            Timestamp: new Date(),
            Body: args
        }
    );
};
photon
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

Thanks, Hamza. Points 1-3 are all very good - I can either open work items for them, or you can just submit a pull request to our GitHub (https://github.com/PlayFab/CloudScriptSamples/tree/master/BasicSample) so that we can review.

For the others:

4. Where are we referencing GetGameList? I can get that updated to point to whatever link you have for that in the Photon docs.

5. Not sure what the context is for this. Is this another sample you want us to include in the docs?

6. Also not sure on this one - we don't return anything from those handlers right now. Where are you seeing State:""?

7. This is potentially confusing - developers who are using App IDs from the Photon integration page in our Add-ons Marketplace are using Photon in our account, and so do not have access to those settings. It's only if they're using an App ID obtained directly from Exit Games that they can do that - in which case I would hope that they're looking at your docs for configuration info.

10 |1200

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

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.