Demo Platform

Game demo platform integration

Role of demo platform integration is allow third party web sites to play demo games from their pages. For game demo platform integration follow next simple steps:

  1. Contact Demo provider to obtain integration credentials.
  2. Select game by ID ([gameId]) form game list (need credentials).
  3. Choose game platform ([platform]) form desktop, mobile or mini.
  4. Create play demo page on your web site and implement next two steps.
  5. Call init game service URL from the page using HTTP basic auth credentials to get [gameServerUrl] and [gameJsLibUrl].
    CURL example:
    curl http://user:passwd@host/demo/game.json?gameId=[gameId]&gamePlatform=[platform]
    PHP HTTP basic auth documentation and examples: php curl, php pear
  6. Generate page with code snippet to run game and replace URLs [gameServerUrl] and [gameJsLibUrl] by the ones obtained as a result of previous calling init game service.
    Game client HTML code snippet:
    <gcw-game gcw-server-url="[gameServerUrl]"></gcw-game>
    <script src="[gameJsLibUrl]" type="text/javascript" charset="utf-8"></script>
    <script>
    	gcw.gameElementsInit();
    </script>
    Game client HTML code snippet with custom game event listener:
    <gcw-game gcw-server-url="[gameServerUrl]"></gcw-game>
    <script src="[gameJsLibUrl]" type="text/javascript" charset="utf-8"></script>
    <script>
    	gcw.gameElementsInit(gameEventListener);
    	function gameEventListener(type, data) {
    		console.log("Game event: " + type, data);
    		if (type == gcw.api.GameEventType.HOME) {
    			window.history.back();
    		}
    	}
    </script>