installing - wxyz-abcd/node-haxball GitHub Wiki

Installing instructions

Installing

Installing as a node.js/CommonJS module

We have to run this command in a command shell to install our library into our development environment:

npm install node-haxball

Now we are ready to import our library with the following code:

const abcHaxballAPI = require("node-haxball");

Installing on browser

  • We have to import these libraries in the given order:

    <script src="https://www.haxball.com/PwfmUfRI/__cache_static__/g/vendor/json5.min.js"></script>
    <script src="https://www.haxball.com/PwfmUfRI/__cache_static__/g/vendor/pako-jszip.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/wxyz-abcd/node-haxball@latest/src/api.js"></script>

Usage

  • Click here for details on the library's constructor.

Usage on node.js

  • We do not need any customization on node.js, the API can directly work out of the box:

    const API = abcHaxballAPI();
  • The constructor structure is exactly the same as browser, except that we do not need to pass anything to the first parameter, it has default values for each key in the first parameter. However, we can customize every parameter if we want.

    const API = abcHaxballAPI(null, {
      proxy: {
        WebSocketUrl: "wss://surf-emerald-armadillo.glitch.me/",
        HttpUrl: "https://surf-emerald-armadillo.glitch.me/rs/"
      }
    });

Usage on browser

  • Currently, there are 2 methods to use our library inside a browser to interact with the original Haxball backend:

    • With proxy setting:

      const API = abcHaxballAPI(window, {
        proxy: {
          WebSocketUrl: "wss://surf-emerald-armadillo.glitch.me/",
          HttpUrl: "https://surf-emerald-armadillo.glitch.me/rs/"
        }
      });
    • Without proxy setting; using our Browser Extension or another mechanism to change origin headers:

      const API = abcHaxballAPI(window); 
  • NOTES:

    • Our proxy server goes to sleep mode if no request is made for about 5 minutes.
    • We also have an always-open alternate url but it does not have a proxy server, so you have to use the extension if you want to work with it.
    • The proxy server is in fact intended to be used publicly by everyone mostly for rapid bot development purposes, but it has the following limitations: (Because we are using the IP address of proxy server while we are using it as an actual proxy server.)
      • Once its IP address gets banned from a room, nobody can join to that room again using this proxy server.
      • If the total number of open rooms created by this proxy server exceeds 2, only 2 of these rooms will be randomly selected and shown to us by Haxball's original backend. (It switches them on each fetch, so that all of them will be shown at different times on different computers.)
    • A private and open source Haxball backend project is also almost ready to be used with this API, so stay tuned for that.
⚠️ **GitHub.com Fallback** ⚠️