Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

Getting started with Cloud Script

  1. a Platform-as-a-Service company Getting Started with Cloud Script Brendan Vanous Senior Developer Success Engineer
  2. Overview • Cloud Script Fundamentals • Adding a Cloud Script • Revision Control • Calling a Cloud Script • Photon Webhooks • Debugging • Usage Scenarios • Limitations • Resources September 10, 2015 1
  3. Cloud Script Fundamentals • JavaScript handlers • Executes in the context of the user, but with server authority • Can call external endpoints • Excellent tool for: • Game updates • Push notifications • Cheat prevention • Player coordination • Cross-service coordination September 10, 2015 2
  4. Adding a Cloud Script September 10, 2015 3
  5. Adding a Cloud Script September 10, 2015 4
  6. Revision Control • Two revisions are active • Test == latest • Live == deployed • Deploy any revision • Note: Live immediately • Versions September 10, 2015 5
  7. Calling a Cloud Script • Query for the active Cloud Script URL POST /client/GetCloudScriptUrl HTTP/1.1 Host: {{TitleID}}.playfabapi.com Content-Type: application/json X-Authentication:{{SessionTicket}} { "Testing": true } • Response { "code": 200, "status": "OK", "data": { "Url": "https://{{TitleID}}.playfablogic.com/1/test" } } September 10, 2015 6
  8. Calling a Cloud Script • Launch the Cloud Script POST /1/prod/client/RunCloudScript HTTP/1.1 Host: {{TitleID}}.playfablogic.com Content-Type: application/json X-Authentication: {{SessionTicket}} { "ActionId": "onLevelComplete“, "ParamsEncoded": "{"level":1}" } • Response • Standard response code • Handler, version, revision • Custom response data • Log (for debugging) • Runtime September 10, 2015 7 { "code": 200, "status": "OK", "data": { "ActionId": "onLevelComplete", "Version": 1, "Revision": 43, "Results": { "rewards": [ { "PlayFabId": "14141CB68CBE4956", "Result": false, "ItemId": "TestItem2", "Annotation": "Given by completing level 1", "UnitPrice": 0 } ] }, "ResultsEncoded": "{"rewards":[{"PlayFabId":"14141CB68CBE4956","Result":false,"ItemId":"TestItem2","Annotati on":"Given by completing level 1","UnitPrice":0}]}", "ActionLog": "", "ExecutionTime": 0.1680013 } }
  9. Photon Webhooks • Partnership with Exit Games • Photon Cloud free with Premium tier • Integrated authentication • Integrated Webhooks • So what are Webhooks? • Calls from Photon Cloud to PlayFab on Room actions • RoomCreated • RoomJoined • RoomEventRaised • RoomPropertyUpdated • RoomLeft • RoomClosed September 10, 2015 8
  10. Debugging • Basic debugging via logging • http://cloudscript.playfab.com/classes/log.html • debug • error • info • Returned with results from script • ActionLog • Debugger in planning • Let us know what you need! September 10, 2015 9
  11. Scenario 1: Updates September 10, 2015 10 • Updating a title is more than just the executable • Changing items • User data • Save values • User Internal Data to track player version • Have an “onLogin” handler • Calls current version handler (“updateToRevN”), passing in player version • If not at this version, call previous version handler • Once returned, update for latest version • onLogin then sets player version
  12. Scenario 2: Player Actions September 10, 2015 11 • For competitive games • Resolution of player action must be server authoritative • Player selects moves, which are sent to Cloud Script • Evaluate moves • Are they possible? • Does the player have the right items? • etc. • On failure, write info to User Internal Data • Use cheat tracking to have cheaters play together
  13. Scenario 3: Rewards September 10, 2015 12 • Determination of rewards for player actions • Player actions are sent to Cloud Script • Evaluate actions • Has enough time passed? • Are the values reasonable? • etc. • On failure, write info to User Internal Data • Use cheat tracking to decide how to manage them
  14. Scenario 4: Messaging September 10, 2015 13 • Push Messages • Require Server authority • Player attacking another player’s base • Player beat a friend’s score • etc. • Player-to-player messages • Write them to Shared Group Data, using ID of PlayFabId • Arbitrary messages, with arbitrary payloads
  15. Scenario 5: Extra Leaderboard Columns September 10, 2015 14 • Shared Group Data • Storage not tied to a particular player • Readable by any player (permission set Public) • Data value per player • Key is the PlayFab ID of the player • Write extra data when updating score • One API call to read players in display
  16. Limitations • An API call is an API call • Total API calls • Apply portion control to your data • Total data returned • How complex is too complex? • Total compute time September 10, 2015 15
  17. Resources • PlayFab Cloud Script Tutorial • https://playfab.com/?post_type=pf_docs&p=1003 • GitHub • https://github.com/PlayFab/CloudScriptSamples • Dave & Buster’s usage • https://playfab.com/blog/dave-busters-goes-mobile-with-playfabs-help/ September 10, 2015 16
  18. QUESTIONS? Twitter @playfabnetwork

Editor's Notes

  1. http://cloudscript.playfab.com/classes/log.html
  2. 17
Advertisement