Test Co-Play

Similar to Instant Games, we've made it really easy for you to test your Co-Play development version locally. This document will explain these steps in detail.

Testing the game from a local server

In order to facilitate the development and testing workflow, we enable developers to run a Co-Play game from a local server while in a Rooms context.

Enabling SSL via localhost

Since our embedded test player is working under the facebook.com domain, it can be served only through HTTPS. In order to embed content in a page served via HTTPS, the embedded content also needs to be served via SSL. The next steps will walk you through setting up a localhost server that serves secure content. We are showing one option below, but there are many solutions possible to enable this behavior.

  1. Install the http-server package via npm. If you don't have npm installed, follow the install instructions on the Node.JS website. After that, run the following command:
    > $ npm install -g http-server
    
  2. Create a private key and a certificate via openssl. This is necessary to run the secure local server.
    > $ cd path/to/my/game/
    > $ openssl genrsa 2048 > key.pem
    > $ openssl req -x509 -days 1000 -new -key key.pem -out cert.pem
    # Fill out necessary information
  3. Run the game from localhost with SSL. Once the key and certificate are ready, you can serve from localhost using SSL.
    # Starts to serve via HTTPS, with cache disabled
    > $ http-server --ssl -c-1 -p 8080 -a 127.0.0.1 
    Starting up http-server, serving ./ through https
    Available on:
    https://127.0.0.1:8080
    Hit CTRL-C to stop the server
  4. After this, navigate your browser to `https://localhost:8080` to see the running game.

Note: You must try to access it at least once, as you might need to approve a security warning from your browser before continuing. If that is the case and you skip this step, your game will not load.

Playing from local server in a Co-Play context

Now that the game is being served from localhost via a secure connection, you can run your game from your local server.

Once you are in a room with an active match, you will see a settings button next to the game player. This feature is available only to users with a Developer or Tester role on the Application. After clicking the button, observe the Developer Options dialog where you can configure the game settings. The game player will refresh immediately running on your local server.

For security reasons, localhost is the only supported domain for testing with the embedded test player.