Cb2 Url Endpoints - lil-lab/cb2 GitHub Wiki

CB2 URL Endpoints

CB2 provides a number of HTTP endpoints for inspecting and accessing user data from a live server instance. This makes it easier to administer experiments with CB2 – server admins can inspect games in-progress live.

Password-protected endpoints

Password protected endpoints contain a 🔒emoji in front of them. To access them, you must provide a ?password= GET URL parameter with the correct password.

Implementation

To make your own password-protected endpoint, make use of the @password_protected decorator in server/util.py. This already fetches the password from the server config and handles hashing and safe password comparison (that is resistant to time-based attacks).

Endpoint URLs

For each of the URLs below, subsitute hostname and port with the hostname and port of your server. For example, if your server is running on localhost:8080, then the URL to view the dashboard would be http://localhost:8080/view/dashboard. You can use either http or https, depending on your server configuration. Port defaults to 8080, but you can change this in the server config. A 🔒 indicates that the endpoint may be password protected. All links go to their respective locations in CB2.

hostname:port/ - The main CB2 page. Contains information about the project and links to the game client.

hostname:port/play - Endpoint which serves front-end WebGL game client. Contains parameters:

  • lobby_name, lets you choose which lobby to join. Default is a google-authenticated lobby.
    • https://cb2.ai/?lobby_name=open - Join the open (no auth required) lobby.
    • https://cb2.ai/?lobby_name=scenario-lobby - Join the scenario lobby (for viewing downloaded scenarios).
    • There’s also the replay lobby, but links to that can be found by navigating to a game from the dashboard.
    • There’s also the mturk lobby, but I’m not giving that out because I don’t want people to intefere with mturk trials. The links are generated automatically for mturkers.
    • There’s also the bot lobby. This is automatically selected if you’re using the CB2 client API to connect to a game.
  • There’s a few other params, for popping up dialogue to bring mturkers straight to their task (instead of needing to click the appropriate UI buttons) and marking a player as a bot by the , but these aren’t really going to be needed by a human navigating the website, so I’ve left them out.
  • In particular for future developers, the URL parameters are mirrored between cb2.ai and subsequent calls to the websocket (cb2.ai/player_endpoint) by the client, and some of the URL parameters don’t have an effect on the server, but they trigger something in the client. So check the C# code as well if you’re trying to figure out why a parameter is doing something.

hostname:port/player_endpoint - Websocket endpoint for the CB2 game client. This is where the game client connects to the server. The client is responsible for sending the correct URL parameters (see above) to this endpoint. This endpoint expects a stream of JSON-serialized objects. For the schema of these objects, see the MessageFromServer and MessageToServer dataclasses.

🔒hostname:port/view/dashboard - A dashboard showing the last 100 games + links to game data & replay. Also includes live statistics about connected clients and a per-lobby status message. Shows live latency, per-client clock drift, and bandwidth. **_New: _**Add parameter ?all=true to see more than 100 games. Warning, this can take a while, and results in a few seconds delay to all currently running games. Recommend not using all=true during mturk trials.

🔒hostname:port/view/client-exceptions - A page to view all uploaded client-side exceptions and stack traces.

🔒hostname:port/status - A JSON status page showing per-lobby info and other server status, number of pre-generated maps in the map pool, etc. Most of this info is in the dashboard (and is parsed by the dashboard). If the dashboard breaks, you can access this page directly.

hostname:port/data/config - The CB2 config currently deployed on the server.

🔒hostname:port/data/download - An endpoint that waits until no mturk games are in progress, then packages (zips) and downloads all server data.

🔒hostname:port/view/stats - (Currently broken) Computes statistics about games played on the server.

🔒hostname:port/view/games - Just shows games. Useful if the dashboard breaks. **_New: _**Add parameter ?all=true to see more than 100 games. Warning, this can take a while, and results in a few seconds delay to all currently running games. Recommend not using all=true during mturk trials.