Is it possible to build a game as HTML5 and have it communicate "outside " the game?

Not sure how to word it, but essentially:
Would it be possible to embed a game into HTML5 and have it communicate/send data to a webpage?
EG: I have a board game embedded into a webpage, and whenever a player wins/loses, a signal is sent to the webpage/data handler and the player’s ratings are updated. (Think lichess, the game is coded in Scala I believe, but the webpage handles player information)

You have multiple options:

  1. Use http.request(). You can send any kind of HTTP request. GET, POST etc. Very few limitations. Good for turn based games or other interaction that doesn’t happen super often.
  2. Use a socket connection. This will convert into a WebSocket. Good for realtime games.
  3. Use html5.run(). Run arbitrary code on the same page as your hosted game.
  4. Use a native extension. This give you total freedom to integrate with any Javascript SDK or C/C++ library. Basically no limitations at all.
3 Likes