Getting started with AirConsol...
Quick Start
8 min
for unity games, please refer to our https //developers2 airconsole com/airconsole unity plugin general idea create a new directory with two files screen html and controller html 2\ include the https //airconsole github io/airconsole api/airconsole 1 9 0 js and use it to communicate between devices 3\ host your files (local/remote) and call airconsole com/# http //your game url/ step by step guide create files create a new directory for your game (e g game) and create two files in it /game screen html screen html controller html controller html the screen html is for the gameconsole's screen the controller html are for the gameconsole's controllers (gamepads) make sure both files can be accessed by http //your local webserver/screen html (or /controller html) if you don't want to create your own screen html and controller html right now and just play around, you can use our pong example https //github com/airconsole/games pong/archive/master zip from https //developers2 airconsole com/pong example include airconsole javascript api file include the airconsole javascript api in both files /screen html /screen html and /controller html /controller html send a message here is a simple example where the controller sends " how are you? " to the screen and the screen replies with " full of pixels! " /controller html /controller html \<button id="btn msg">send message\</button> \<script type="text/javascript"> var airconsole = new airconsole(); // when we press our button, we send a message to the screen document getelementbyid('btn msg') addeventlistener("click", function() { airconsole message(airconsole screen, "how are you?"); }); // listen for messages airconsole onmessage = function(from, data) { // show message on device screen var info = document createelement('div'); info innerhtml = data; document body appendchild(info); }; \</script> /screen html /screen html \<script type="text/javascript"> var airconsole = new airconsole(); // listen for messages from other devices airconsole onmessage = function(from, data) { // we receive a message > send message back to the device airconsole message(from, "full of pixels!"); // show message on device screen var info = document createelement('div'); info innerhtml = data; document body appendchild(info); }; \</script> test your game you need to start a local webserver in your /game folder to serve the screen html screen html and controller html controller html in this example we will host the two files on http //192 168 0 1 8080/screen html http //192 168 0 1 8080/controller html to run the game, go with the browser that should act as the screen to http //www airconsole com/#http //192 168 0 1 8080/ note there is no screen html at the end! game controllers (your smartphone) can join as usual over https //www airconsole com enter the code you see on the screen the devices should now exchange the messages simulator if you append /simulator in the url, then you will get a split view of the screen and two controllers http //www airconsole com/simulator/#http //192 168 0 1 8080/ this makes testing and developing a lot easier if you run into issue with https (mixed content issues), refer to the https //developers2 airconsole com/testing with your phone#0a3qq device ids important warning make sure you do not assume that the controllers have device ids 1, 2, 3 we strongly recommend you read the https //developers2 airconsole com/device ids and state guide! next steps checkout the guide about our https //developers2 airconsole com/pong example or the https //airconsole github io/airconsole api/ to learn more about how to build games for airconsole to getting started with uploading your game to airconsole, you can log in here https //www airconsole com/developers