Haxe
You’re encouraged to use this SDK along with any Haxe Game Engine, such as: OpenFL, Kha, HaxeFlixel, Heaps, HaxePunk, etc.
Install package
Install colyseus from haxelib:
haxelib install colyseusSDK Example Project
The colyseus-hx repository contains an example project that can be compiled to html5, neko, cpp, ios, etc.
Compiling the example project to html5
git clone https://github.com/colyseus/colyseus-hx.git
cd colyseus-hx/example/openfl
# Install haxelib dependencies
haxelib install openfl
haxelib install lime
haxelib install tink_http
haxelib install tink_await
haxelib install swf
haxelib install colyseus-websocket
# Compile the project
haxelib run lime test project.xml html5Running the test server locally
To run the test server locally, you will need to run the following commands in your terminal:
git clone https://github.com/colyseus/sdks-test-server
cd sdks-test-server
npm install
npm startYou can see the source code for the test server here.
You should be able to see the server running at http://localhost:2567, and the example project will be able to connect to it.
SDK API
Navigate to the Client SDK for API Reference, and select the Haxe tab.
State Schema Codegen
For compiled languages like Haxe, you need to generate client-side schema classes that match your server’s state structure. Run the following command from your server directory:
npx schema-codegen src/rooms/schema/* --haxe --output ../src/schema/See the full State Schema Codegen documentation for more options and details.
ios target caveats
You may need to manually apply this patch in order to compile for iOS: HaxeFoundation/hxcpp@5f63d23
Haxe
Cocos Creator
Discord Activity