question

Denzie Gray avatar image
Denzie Gray asked

Is there an Updated guide for Async Photon Unity? Turnbased Chess Game

I took a look at:
https://community.playfab.com/questions/9573/memorydemocloudscript-question.html?childToView=10075#comment-10075

and:
https://community.playfab.com/questions/515/207129407-Persistent-turn-based-games-.html

And I have some questions in regards to integrating Async Multiplayer in our game.

The game is a Chess Variant built in Unity and I am looking for the best practices for creating and loading the games and storing completed games for a replay feature.

The threads above mention Shared Group Data and User Group Data having a 100 key limit.

Is there another way/API in playfab to cache the games?

https://community.playfab.com/questions/668/208478838-GetGameList-implementation-in-Photon-Cloudscript-example-missing.html

The above thread seems outdated but doesn't offer a new option.

Using this next link for the following questions:
https://github.com/JohnTube/MemoryDemoCloudScript/blob/master/MemoryDemo.js

In regards to Photon, when we return an response other than 0(considered "SUCCESS"), does that error prevent the intercepted call from completing? Could a dev use this to prevent state change?

In "if(args.Type==='Create')" on line 274, we have an if statement, is this value based solely on the users command? What I mean is say the Room already exists and I call the create method as a client will the handler on 268 be called or will the client be rejected? And what if I call Create and the room is cached/inactive? Do I have to check all saved rooms?


The last ones are probably questions for Hamza.

There seems to be some ambiguity in what Photon abdicates to PlayFab/External Webhooks and I would like some clarity. An updated Turn based example would be useful. Does one exist?

Thanks for reading. I look forward to a long discussion.

Player Dataunity3dphotonShared Group Data
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

·
Hamza Lazaar avatar image
Hamza Lazaar answered

Hi @Denzie Gray,

Thank you for choosing Photon!

Hamza here, replying to questions addressed to me or related to Photon:

"In regards to Photon, when we return an response other than 0(considered "SUCCESS"), does that error prevent the intercepted call from completing?"

As you can read in the documentation here, ResultCode!=0 in PathCreate response (and IsPersistent is true and both PathCreate & PathClose) will result in a failure of room creation (or loading): client will receive error code 32752.

In all other hooks except PathGameClose, if ResultCode!=0 and if HasErrorInfo is true, all joined clients will receive ErrorInfo event but the operation itself triggering the hook will be processed successfully. In PathClose, simply nothing special happens no matter the ResultCode value the room will be removed from Photon server.

"does that error prevent the intercepted call from completing?" ==> yes and no. yes in PathGameCreate and IsPersistent is true and both PathCreate & PathClose are configured. no in others.

"Could a dev use this to prevent state change?" ==> not sure I get this but the idea behind it is to allow or not room creation or loading when persistence is used.

"In "if(args.Type==='Create')" on line 274, we have an if statement, is this value based solely on the users command? What I mean is say the Room already exists and I call the create method as a client will the handler on 268 be called or will the client be rejected? And what if I call Create and the room is cached/inactive? Do I have to check all saved rooms?"

most of the following is just summarizing or rewriting the webhooks documentation page:

A. If the client calls CreateRoom:

A.1. if the room exists/lives in Photon server, no webhook triggered and an error (32766) will be returned to the client.

A.2. if the room does not exist in Photon server, PathCreate webhook will be triggered with argument Type == Create.

B. if the client calls JoinRoom:

B.1. if the room exists/lives in Photon server, PathJoin webhook will be triggered.

B.2. if the room does not exist in Photon server, if AsyncJoin is true (or not configured) and IsPersistent is true and both PathCreate & PathClose are configured PathCreate webhook will be triggered with argument Type == Load. otherwise, no webhook triggered and an error (32758) will be returned to the client.

C. if the client calls JoinOrCreateRoom:

C.1. if the room exists/lives in Photon server, PathJoin webhook will be triggered.

C.2. if the room does not exist in Photon server, if AsyncJoin is true (or not configured) and IsPersistent is true and both PathCreate & PathClose are configured PathCreate webhook will be triggered with argument Type == Load. otherwise, no webhook triggered and the room will be created.

D. if the client calls RejoinRoom:

D.1. if the room exists/lives in Photon server, PathJoin webhook will be triggered.

D.2. if the room does not exist in Photon server, if IsPersistent is true and both PathCreate & PathClose are configured PathCreate webhook will be triggered with argument Type == Load. otherwise, no webhook triggered and the room will be created.

---

After that, in PathCreate, it's your responsibility to allow or disallow room creation or return any previously saved room state.

"There seems to be some ambiguity in what Photon abdicates to PlayFab/External Webhooks and I would like some clarity. An updated Turn based example would be useful. Does one exist?"
there is no demo and I don't think there will be any time soon.

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

Hamza Lazaar avatar image Hamza Lazaar commented ·
1 Like 1 ·
Denzie Gray avatar image Denzie Gray commented ·

First, Thanks for the response!

C.2. if the room does not exist in Photon server, if AsyncJoin is true (or not configured) and IsPersistent is trueand bothPathCreate & PathClose are configured PathCreate webhook will be triggered with argument Type == Load. otherwise, no webhook triggered and the room will be created.


When you mean otherwise, you mean that if AsyncJoin or etc is not set? ex:
JoinOrCreate will be Type == Create if Async & IsPersistent &
and both PathCreate & PathClose are configured and the room does not exist?


Are there any plans to allow the interception of the other handlers similar to PathCreate?


If I edit the 'State' during RoomPropertyUpdates could I return it to users as a way to
enforce valid state? I ask because in your Load example of MemorDemoCloud.js I saw you return 'State'.


Lastly When I send an error to the client, the log returns the PhotonSecretKey in the message. Is this a bug? I set ErrorInfo to false and waited and I still saw the Key. Is there a setting to disable it?

0 Likes 0 ·
Hamza Lazaar avatar image Hamza Lazaar Denzie Gray commented ·

"When you mean otherwise, you mean that if AsyncJoin or etc is not set?"

I mean any of the conditions is not met: AsyncJoin is false, IsPersistent is false, PathCreate is not configured, PathClose is not configured.
"Are there any plans to allow the interception of the other handlers similar to PathCreate?" not in the near future, no ETA.

"If I edit the 'State' during RoomPropertyUpdates could I return it to users as a way to enforce valid state?"
State can be edited but this is not recommended and risky and we do not fully support this as State can become broken easily. I personally modify State but in order for this to take effect:
- edit only the nonbinary parts.
- keep same types and range, etc. values changed should be valid.

- if you add or remove values also, State should remain valid still.
- modify State given in PathClose, Type="save" and return modified version in response to PathCreate, Type="Load"
"
Is there a setting to disable it?"
No.

1 Like 1 ·
Denzie Gray avatar image Denzie Gray Hamza Lazaar commented ·

1:

"State can be edited but this is not recommended and risky and we do not fully support this as State can become broken easily. I personally modify State but in order for this to take effect:
- edit only the nonbinary parts.
- keep same types and range, etc. values changed should be valid.

- if you add or remove values also, State should remain valid still."


Ok, my question here is if I change the state at that time, could I return it like in RoomCreate?


Say a user changes a value and RoomPropertyUpdated is triggered:

If I follow your guidelines and alter the 'State' in the call would they get the changes

I made included in the update?


2:

"Is there a setting to disable it?"
No.

For your last response, isn't it dangerous to send the Secret Key?
Right now, a user could read it in the player.logs. Is this not a problem? Wouldn't a user be able to make calls to the API? How can I send a non-0 ResultCode without exposing the key?

In a previous thread there was a limit of 100 games. Is that still the case?


Thanks again for responding.

EDIT:

If a client sets webhooks to false via a hack or w.e., would the command execute?
I mean if they set room propertites with webforward == false.

0 Likes 0 ·
Show more comments
Show more comments

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.