Multiplayer API

So I usually use PlayerIO for simple multiplayer functionality.
But since they don’t have a HaXe version of their API, what other resources would you recommend for networking capabilities?

I’m currently developing a multiplayer game with MPHX, a tcp library written in Haxe, As well as a node rest api I’ve written myself to handle the authentication.

Mphx is far from mature but it’s easy to work w and I’ve forked my own branch to adapt it to my own needs and it’s taking shape!

I’m currently on my phone but if you have any specific questions, feel free!

Sorry for the noobishness but how do you implement this?
I’m new to guthub and using command lines, I’m one of the latecomers to HaXe as well.
Do I have to download the library, run command line and add a haxelib tag to the project.xml?

So I ran
haxelib install mphx
and added
haxelib name=“mphx” />
to project.xml but I can’t import mphx classes.
What am I missing?

If you’re targeting html5 try out firebase

Hopefully in the near future we can add wrappers for the firebase android/ios libraries as well as it solves a lot of problems ( live db through sockets, handling while offline, offline storage, auto-syncing, online login handling, asset storage, etc. )

1 Like

I’d rather go for an all HaXe implementation so i can export to html5 flash and android.
Seriously needing a tutorial for this though.
Tutorial for installing haxelibs anyone?

Hey! Sorry for reviving this old-ish thread but…

Are there any tutorials where to start with this? Or examples? I got FirebaseExtern downloaded & very intrigued to learn, but got no idea where to start :slight_smile:

If you’re working on html5 then that will be just adding the external js file from firebase, and the externs should help you with the functions and structure of the calls that you need

The feature you’re going for is the firebase.database() feature. I’d say don’t worry about auth etc in the first steps, just get a simple data storage running first ( e.g. config settings , ladder , game lobby ) and then after that client communication

Here’s an example for a live chat and here a shared notepad


Ooooh, thank you so much :slight_smile: time to start learning!

I see that firebase docs you linked to has c++ tab… would you recommend using firebase for windows target? Working on targeting html5 now though, so just asking.

Oh that’s pretty sweet, but I think it’s for mobile only

What I’ve seen people do is adding a Node.js wrapper that they communicate with, and use the js library on desktop. See

What also works is communicating with FB through their REST API, which works pretty much everywhere. You’d just lose live capabilities unless you’d use a REST API that supports REST event streaming - I’d go with sockets though if you can

Hey @Fixxel did you manage to get this working?
After some consideration I’ve decided to give it another shot.
Having trouble with the basics though, not sure how to include the external js file and I think FirebaseExtern is referencing a deprecated API.
Could you walk me through the steps if you managed to get it working?

1 Like

Ok I added this code to index.html above the references to howler.min.js, pako.min.js etc.

<script src=""></script>
  // Initialize Firebase
  var config = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>",
    databaseURL: "https://<DATABASE_NAME>",
    storageBucket: "<BUCKET>",
    messagingSenderId: "<SENDER_ID>",

Replaced the values with the values from the firebase console.
Tried to get a reference to the database using FirebaseExtern:

var dbRef:Firebase = new Firebase("myUrl");

Getting this error:
ReferenceError: Firebase is not defined

I figure that means I haven’t included firebase.js properly.
If so, how do I do this?

Maybe I have to rewrite the extern classes?
Any advice on that?

Ok I installed this haxelib for the extern.
It looks more up to date than the other one.
I’m using haxe 3.2.1 so I added this

<haxeflag name="-D" value="js-classic" />

Is that the right way to do it?
I’m now getting this error

lime is not defined

Any help is greatly appreciated!

haxelib install lime 5.3.0 --no-timeout
Sit back and relax.

I’m not sure if the libraries you’re using are going to work with lime 5.3.0 though.

I already have lime 5.3.0 installed.
The js-classic haxeflag removes an anonymous function, details here.
Just tried changing this:

<haxeflag name="-D" value="js-classic" />

To this:

<haxeflag name="-D" value="-js-classic" />

That seems to have fixed the lime issue, now I’m getting this:

q is undefined

q seems to be located in a massive block of code in my Test.js underneath this:

/*! @license Firebase v3.6.0
    Build: 3.6.0-rc.3
    Copyright (c) 2010, Linden Research, Inc.

I think that comes from the firebase.js file now included in the Test.js file which I didn’t do.
The firebase extern has this line in it:


But my lib folder doesn’t include a firebase.js file so I’m a bit puzzled how it ended up in there.

Found the lib folder in the haxelib not my project bin.
Updated the firebase.js to version 4.2.0 to see what would happen…

k is not defined

Why would that throw errors when compiling from OpenFL but not for everyone else using the same file?

Are you compiling using dead-code elimination, or using -final with OpenFL or Lime?

Is that this one?

<haxeflag name="-dce full" />

It’s there but it’s commented out.
How and why do you use -final?
In fact is there a tutorial for all the project.xml options?


just to add a voice, we are using Smartfoxserver 2X in our games and we are currently porting to Haxe. There is an inofficial Smartfox API for Haxe (which I proudly contributed to) here:

Our initial tests show no problems in Flash and HTML5 targets that we tested.