Turn Based Memory Demo Help (parse.com)

Options
I am new to Photon but after evaluating the other solutions out there, it seems to be the best in its features/pricing.

I have looked through the Memory Demo and it was a good starting point for what I wanted to do.

My game is a turn-based game similar to Words With Friends but using cards (strategic turn based). So similar to the Memory Demo, I need a way to have multiple games running, where you can jump in and out while waiting for the other player to play.

In my app, I already use 'parse' (http://www.parse.com) for a lot of the cloud storage and was wondering if there was a tutorial or documentation on how to get my WebHooks to work with 'parse'.

There is a javascript backend for parse which I use to do a lot of my cloud based transactions with the parse database. Would I add more calls to this and setup the respective functions in the WebHooks UI on the photon app setup ?

Any help would be appreciated.

Thanks!

Comments

  • Philip
    Philip
    edited July 2014
    Options
    Hi,

    we don't have a tutorial for parse, but it shouldn't be hard to get that working.
    Since webscript(lua) and heroku(python) are currently outdated.
    The best way to get started at the moment is with our .net demo:
    https://github.com/exitgames/photon.web ... based.waws

    To develop locally I use https://ngrok.com/ to setup a tunnel to my dev machine.
    Just download the exe and start it like this:
    ngrok.exe -subdomain=yoursubdomain 8080

    In the webhooks you only have to re-configure the url:
    http://yoursubdomain.ngrok.com/...

    In your browser you can see the request/responses.

    -Philip
  • Philip
    Options
    Hi again,

    the webscript lua scripts are now up to date:
    https://github.com/exitgames/photon.web ... .webscript

    They don't have the PushWoosh pushnotifications integration, but it does show how to access the information we
    use in .net. to trigger the Pushnotification. Check out the script GameProperties.

    -Philip
  • Well I looked into the setup for Azure and using it versus the Webscripts.io version but it seems very Windows dependent.

    Our game is primarily on IOS devices to start off and so it seems a bit of a hassle setting up since most of our development machines are Mac's.

    Thanks for updating the webscript lua stuff will check it out.
  • Philip
    Options
    Hi ZenCoder,

    in case you are still interested we just released the parse version of webhooks
    https://github.com/exitgames/photon.web ... sed.parse/

    Here a little FAQ that you might find helpful to get started ...

    > 1)
    > What is the link I give to the Webhooks in my Turn Based Application on https://www.exitgames.com/en/Turnbased/Dashboard ?
    >
    > For example :
    > Here is a debug javascript function we use to create a bunch of default cards for the player
    >
    > curl -X POST \
    > -H "X-Parse-Application-Id: PARSE_APP_ID" \
    > -H "X-Parse-REST-API-Key: PARSE_REST_API_KEY" \
    > -H "Content-Type: application/json" \
    > -d '{"parsePlayerId": "xhasdjasd"}' \
    > https://api.parse.com/1/functions/creat ... Collection
    >
    > Apart from the parameters passed to this function (everything following -d), there is an App ID and Parse REST Key.
    >
    > Where does Photon read this from ?

    Parse allows two ways to access your custom code
    a) Parse Functions: which are mainly to be accessed by their sdks (clients) and requires the parse specific headers.
    b) Cutsom Hooks: that don't require the headers https://parse.com/docs/cloud_code_guide#webhooks
    Your example refers to a) but photon cloud webhooks don't support custom headers so we use b).

    To set it up for your app:
    1. setup your application - lets assume you call it "my-parse-app"
    2. setup the sub domain to reach your rest app in "webhosting"
    - https://www.parse.com/apps (edit your app or)
    - https://www.parse.com/apps/my-parse-app/edit#settings (edit webhosting)
    - https://www.parse.com/apps/my-parse-app/edit#hosting
    - set "parse app name" my-parse-app

    In the Photon dashboard you only need to set:
    - https://my-parse-app.parseapp.com

    Note: for development we find it quite helpful to use a service like http://runscope.com.

    > 2.)
    > The second piece of information I need is a little more clarification on how
    > Webhooks/Photon Rooms work internally. I hunted around on the client for more
    > information but wasn't able to say for certain where some of these functions get called. More specifically :
    > a) When is GameCreate, GameLeave, GameProperties, GameClose, GameEvent, GameJoin called ?
    > I could rely on the Client callbacks for some of these but would like a better understanding of how it works internally.

    #Webhooks: The Architecture is
    Client ---> PhotonCloud ----> Webhooks

    1. GameCreate
    This hook is called when a new room is created. And to load the state (if IsPersistent is "true") the hook is called on the first player re-joining only if the room was already removed from the Photon Cloud Servers.
    2. GameClose
    When a room is removed from the Photon Cloud Servers we call PathClose. If IsPersistent is set to "true" the room state is sent. You can use the room state to persist your game's state.
    3. GameJoin
    Called when the second+ player joins (or re-joins) the room. If a empty and not yet removed room is rejoined this hook is called for the first re-joiner since there is not required to load the state.
    4. GameLeave
    Called when a player leaves the room.
    5. GameEvent
    Called when the client raises an event in the room with the flag HttpForward set true.
    6. GameProperties
    Called when the client sets a room property with the flag HttpForward set true.

    For the last two (5+6) the client decides if the call is forwarded to the webhooks (default is false).
    The memory demo uses 6.

    #WebRpc

    You can use WebRpc this to call any other entry point of your REST api's, the Architecture is the same as in webhooks
    and we use the same base url of the webhooks.
    In the client you define the Path to be called (can contain get paramters). The data you send will be auto converted to json
    and posted to your REST service on the way back the json data you return will be auto converted and returned to your client.

    You can have look in the client on how we call GetGameList.

    Note: This might not be so interesting to use if your client already uses the parse sdk's that allow you to easily do that directly with parse.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi Philip,

    I want to ask you about the fields "Binary" and their respective "DEBUG_BINARY"/"DEBUG_BINARY_18" :
    I think binary fields are the encrypted ones ? Maybe I'm wrong. But in the json data there's a binary field per Actor (player/user) with a respective "DEBUG_BINARY" field that has a value of {"1":{"255":"userId"}} and there is another Binary field outside the ActorsList followed by a "DEBUG_BINARY_18" field showing {"250":[PublicCustomPropertiesKeys],"253":false,"254":false,"255":2,PublicCustomProperties(Key,Value)}.

    So how to remove the debug fields once development ended. I couldn't find any code with value 18, so what is it ?