⚔ Multiplayer Game Client for Haxe
Clone or download

README.md



Patreon donate button Discussion forum

Multiplayer Game Client for Haxe
View documentation

Example

The example project can be compiled to html5, neko, cpp, ios, etc.

It uses the state_handler room from the colyseus-examples project, which you can find here.

Compiling it to html5 (live demo)

lime build project.xml html5

Usage

Connecting to server:

import io.colyseus.Client;
import io.colyseus.Room;

var client = new Client('ws://localhost:2657');

Joining to a room:

var room = client.join("room_name");
room.onJoin = function() {
    trace(client.id + " joined " + room.name);
}

Listening to room state change:

Listening to entities being added/removed from the room:

room.listen("entities/:id", function (change) {
    trace("new entity " +  change.path.id + " => " + change.value);
});

Listening to entity attributes being added/replaced/removed:

room.listen("entities/:id/:attribute", function (change) {
    trace("entity " + change.path.id + " changed attribute " + change.path.attribute + " to " + change.value);
});

Other room events

Room state has been updated:

room.onStateChange = function(state) {
  // full new state avaialble on 'state' variable
}

Message broadcasted from server or directly to this client:

room.onMessage = function (message) {
  trace(client.id + " received on " + room.name + ": " + message);
}

Server error occurred:

room.onError = function() {
  trace(client.id + " couldn't join " + room.name);
}

The client left the room:

room.onLeave = function() {
  trace(client.id + " left " + room.name);
}

ios target caveats

You may need to manually apply this patch in order to compile for iOS: HaxeFoundation/hxcpp@5f63d23

More info: http://community.openfl.org/t/solved-system-not-available-on-ios-with-xcode-9-0/9683?source_topic_id=10046

License

MIT