php - How would I handle game actions through a REST API? -


i have php-based game works in typical request/response fashion, generating , outputting pages. wish separate presentation , game logic, porting api-based (using phalcon). allow me make mobile app can interact same code base.

i'm new whole rest api thing trying follow guidelines set forth in restful web services. understanding api should work follows:

post /v1/users adds new user. /v1/users returns list of existing users... , on. 

however, client consuming api (via ajax likely) should issue higher-level commands. example, don't want savvy user making api call modifies experience. instead, data modification side effect of game action takes place based on player input.

for example, client may "hey, attack monster", @ point server verify player has enough energy, carry out attack, add gold , experience player, , return result client. these actions transactional, multiple conditions needing true , multiple results needing occur in order action considered successful.

i picture functioning somewhere along lines of:

/v1/attack/player - id of player being post variable. /v1/work - amount of time being worked post variable. 

however, seems fall under rpc type of architecture, defined in book, understand not same.

  • how handle scenario?
  • am correct in thinking rest api appropriate this? seem nature of me needing call remote procedures fundamentally against i'm reading rest is.
  • assuming approaching wrong mindset - there other architecture better suited or should continue way mentioned seeing work?

any advice on whether i'm headed in right direction , can better beneficial me.

thank you.

i send post /attack , describe parameters in body. create links every opponent. might work simple games, server won't able push data browser, unless use polling.

for realtime games event based approach websockets better...


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -