haxball.js is a powerful Node.js module that allows you to easily interact with the Haxball Headless API.
- ๐ค How To Use
- ๐ Technologies
- ๐ฑ Minimal Requirements
- ๐ Features
- ๐ก How To Contribute
- ๐ค Contributors
- ๐ค Author
- ๐ License
npm install haxball.js
// room.js
const HaxballJS = require("haxball.js");
HaxballJS.then((HBInit) => {
// Same as in Haxball Headless Host Documentation
const room = HBInit({
roomName: "Haxball.JS",
maxPlayers: 16,
public: true,
noPlayer: true,
token: "YOUR_TOKEN_HERE", // Required
});
room.setDefaultStadium("Big");
room.setScoreLimit(5);
room.setTimeLimit(0);
room.onRoomLink = function (link) {
console.log(link);
};
});
Haxball has a limit of 2 rooms per IP. Therefore, you can use proxy with adding proxy: "<YOUR_PROXY_IP>"
in your RoomConfig.
Example:
HBInit({
...
proxy: "http://1.1.1.1:80",
});
From v2.1.0, the package has basic typings included. Typings are automatically imported alongside haxball.js
package.
Install TypeScript and ts-node in your project:
npm install typescript --save-dev
npm install ts-node --save-dev
Name the file room.ts
instead of room.js
and use example room code from the previous section.
You may run the server with ts-node room.ts
instead of node room.js
. To make it runnable with npm start
, add the alias to package.json
:
// package.json
//...
"scripts": {
"start": "ts-node run.ts"
}
//...
- wrtc - WebRTC implementation for NodeJS
- ws - Websocket Connection
- json5 - JSON Helper Module
- @peculiar/webcrypto - Webcrypto implementation for NodeJS
- pako - ZLIB port for NodeJS
- xhr2 - W3C XMLHttpRequest implementation for NodeJS
- http-proxy-agent - Websocket Proxy Support
- @types/haxball-headless-browser - Type definitions
- NPM
- NodeJS Version >=18
- Promise based
- Synchronous
- Performant
- Strongly Typed
- Make a fork of this repository
- Clone to you machine and entry on respective paste
- Create a branch with your resource:
git checkout -b my-feature
- Commit your changes:
git commit -m 'feat: My new feature'
- Push your branch:
git push origin my-feature
- A green button will appear at the beginning of this repository
- Click to open and fill in the pull request information
Contributions, issues and features requests are welcome!
๐ฎ Submit PRs to help solve issues or add features
๐ Find and report issues
๐ Star the project
Copyright ยฉ 2023 Mertushka mertushka@proton.me
This project is licensed by MIT License.
This README was generated with ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ by readme-template-generator