wynemo
6/17/2013 - 9:35 AM

flox.txt

flox


注册一款游戏 会获得game-id, game-key

玩家认证

 玩家都会分贝到唯一的ID

 这个ID 与玩家游戏数据对应

 guest 认证
    点登出按钮
    清空浏览器缓存
    游戏数据就会丢失

 key 认证

 email 认证

   玩家提供邮箱 玩家在邮件里点确认

不同游戏玩家的id不同

1. login


POST https://www.flox.cc/api/

post-data(json) 


{
    method : post
    url: /api/games/game-id/authenticate
    headers: {
        content-type: appliation/json
        x-flox: {
            sdk: {
                 type: as3
                 version: 0.6
            }
            player: {
                id: playerId
                authType: email
                authId: player-email-address
                authToken:installationID(为随机生成的12位字节)
            }
            gameKey: game-key
            bodyCompression: zlib
            dispatchTime: now-time
       }
   }
   body: {
       authType:email,
       authId:player-email-address,
       authToken:installationID(为随机生成的12位字节)
       id:playerId(play 为guest时有此字段, 为随机生成的12位字节)
   }
}


return:
json 
{
status
}


2.session (queue)
POST https://www.flox.cc/api/

url:/api/games/game-id/.analytics

body: {
    startTime: -
    gameVersion: -
    languageCode: -
    deviceInfo {
        resolution: -
        os: -
        flashPlayerType: -
        flashPlayerVersion: -
    }
    fistStartTime: -
    lastStartTime: -
    lastDuration: -
    lastLog: -(上次日志, 所以要第二次登录才会在web界面有日志)
}

3.entity (player's game data)



save entity:

  url:/api/games/game-id/entities/entity-class-name/id

  method : post
  body 	{
	id (自己指定名称)
	CreatedAt
	UpdateAt
	OwnerId (current player's id if not null)
	PublicAccess (read/write/readwrite)

	CustomField = ? (要保存的自定义字段)
   }


load entity

  url:/api/games/game-id/entities/entity-class-name/id
  method: get
  body: null

destory entity

  url:/api/games/game-id/entities/entity-class-name/id
  method: delete
  body: null


4. 查询 (返回符合条件的多个查询集)

 url:/api/games/game-id/entities/entity-class-name
 method: post
 body : {
   where (field =/>/?/... value)
   offset (用于分页)
   limit
 }

 return
 
 [etag, id]

 if etag in loacl_cache:
      return loacl_cache[etag]
 else:
     use loadEntity(id)

Restrictions & Limitations

Complex properties: You can not index or query for complex properties like arrays, lists, maps or dictionaries. These are object hierarchies and need to be serialized by flox.
Not-equal filters: You can only use one '!=' filter condition per query.
Response time: If your queries load too many entities at once, you may run in a 30s response time limit. Any request that reaches the flox server must not take longer than 30s.


5. Leaderboard

排行榜

发送分数(queue)

url:/api/games/game-id/.score
method: post
body : {
    leaderboardID,
    playerName,
    score
}


url:/api/games/game-id/.score
method: get
body : {
    leaderboardID,
    timescope,
    limit=50
}