AS3 API port to Haxe ?

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

abcd
Posts: 15
Joined: 11 Jan 2008, 18:26

AS3 API port to Haxe ?

Postby abcd » 03 Oct 2013, 18:16

Are you considering to port the current AS3 client to pure Haxe code ? The big advantage will be performance and with haxe can easy target any platform - iOS, Android, Flash, html 5. Haxe have a strong community and many flash developers using haxe now.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: AS3 API port to Haxe ?

Postby Bax » 04 Oct 2013, 14:59

Not at the moment. Anyway all platforms you mentioned are already covered by the native APIs we distribute.
Paolo Bax
The SmartFoxServer Team
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: AS3 API port to Haxe ?

Postby Lapo » 04 Oct 2013, 15:00

And by other popular platforms such as Flash, Unity and C++
Lapo
--
gotoAndPlay()
...addicted to flash games
Boorik
Posts: 14
Joined: 02 Dec 2014, 15:01
Contact:

Re: AS3 API port to Haxe ?

Postby Boorik » 02 Dec 2014, 16:45

Hi,

I'm using this subject to ask If someone now has already made the port of the client to http://haxe.org/ or as created an extension for http://www.openfl.org/ ?
With my company we are already using smartfox with haxe and the flash client but we need to go multiplateform. For this port haxe is pretty at ease using openfl.
However the sfs client need a wrapper in haxe and not beeing a swc.
I think we can do it from our side but it will be really simplier if we can have access to as3 sources. A clean port can be done and may be really multiplateform.
If nothing already exists can you give us access to as3 sources?

Thank you
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: AS3 API port to Haxe ?

Postby Lapo » 03 Dec 2014, 09:36

Hi,
send us an email to the support@... email box and we'll send the sources over.

Thanks,
Marco
Lapo

--

gotoAndPlay()

...addicted to flash games
sac2play
Posts: 1
Joined: 12 Jan 2015, 08:35

Re: AS3 API port to Haxe ?

Postby sac2play » 12 Jan 2015, 09:50

Hi Boorik,

We are in the same boat, where we want to integrate the SFS2x api to Haxe/openFL. How has your implementation turned out to be ? can you please give some insight, we are very eager to know if the direction we are taking is right.

Regards,
Sac
Boorik
Posts: 14
Joined: 02 Dec 2014, 15:01
Contact:

Re: AS3 API port to Haxe ?

Postby Boorik » 27 May 2016, 07:33

Hi,

I'm back, on this conversion.
Currently I'm facing an issue on the meaning of this code in SFSIOHandler.as, function handleNewPacket :

L138 :
// Resize the array
return resizeByteArray(data, 1, length - 1)

What does the length refer to? is it data.length?

Thank you for helping
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: AS3 API port to Haxe ?

Postby Lapo » 27 May 2016, 08:22

Hi,
thanks for spotting this. It is quite odd :shock: :)

You're right, length is not defined as a local or variable or class variable therefore it should simply cause a compilation error and yet it doesn't. Additionally the superclass is Object which doesn't have any length properties.

I opened up Flash, and tried this code:

Code: Select all

function test():void
{
   trace("len: " + length)
}

Without any variable length defined, this is what I see:

Code: Select all

len: 1


So why does the code works even if it looks wrong? Because in the line you have reported we end up calling

Code: Select all

ByteArray.writeByte(data, 1, 1 - 1)

and when the last argument is zero it copies the entire content of the byte array, which is exactly what we want! :shock: :D

So yeah, this is the perfect phantom bug... it compiles without errors, and it runs correctly! You could even argue that it is not a bug, since passing 0 works the same as passing the full length of the byte array.

Fascinating!

Anyway, back to your question --> As you suggested the correct version should be data.length :)

Cheers

p.s. = I am still puzzled as to where is this length variable is coming from... any ideas?
Lapo

--

gotoAndPlay()

...addicted to flash games
Boorik
Posts: 14
Joined: 02 Dec 2014, 15:01
Contact:

Re: AS3 API port to Haxe ?

Postby Boorik » 27 May 2016, 12:59

Thank you for answer.

I have no idea too :)

Have you some sort of test classes to validate my translation?

It is compiling but I need to know if everything is working fine.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: AS3 API port to Haxe ?

Postby Lapo » 27 May 2016, 14:58

I know it is correct, because data.length is what we have in the code of the Java and C# API. So no problem there.
Lapo

--

gotoAndPlay()

...addicted to flash games
Boorik
Posts: 14
Joined: 02 Dec 2014, 15:01
Contact:

Re: AS3 API port to Haxe ?

Postby Boorik » 30 May 2016, 07:26

Sorry,

That's not what I was trying to say. I'm sure data.length is the good answer.
But I have done a first version of the haxe client, currently compiling to flash and c++, using openfl framework.
I was wondering if you have some kind of unit tests to validate that everything I have done is working as expected.
Or anything that can be used in this purpose.

Thank you.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: AS3 API port to Haxe ?

Postby Lapo » 30 May 2016, 09:49

Oh I see. My bad.

Typically what you want to do is building small applications that test each aspect of the API, such as basic connection/login, Messages (public/private/mod/admin), RoomVariables etc...

You could take a look at the Flash Example pack we provide and translate those examples to Haxe, maybe simplifying the UI bells and whistles to speed up the process.

Also, as a side note, if you're interested in sharing the API with the rest of the community we could host them on our website, giving you full credit for the work. We would regard them as "unofficial" since we don't maintain them but we'd be happy to forward to you potential customers and users interested in using them etc...

Just throwing the idea there, if you're interested. :)

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Boorik
Posts: 14
Joined: 02 Dec 2014, 15:01
Contact:

Re: AS3 API port to Haxe ?

Postby Boorik » 30 May 2016, 11:40

I'm interested but can it be opensourced on github?

updates and community improvements are really easier with it.

Anyway it must work correctly before spreading :)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: AS3 API port to Haxe ?

Postby Lapo » 30 May 2016, 13:28

Sure, makes sense.
We could add your work to the list of available API, when they're ready and a link to your website or some other contact info for people interested in getting in touch etc...

Let us know when you think you're ready.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Boorik
Posts: 14
Joined: 02 Dec 2014, 15:01
Contact:

Re: AS3 API port to Haxe ?

Postby Boorik » 31 May 2016, 13:17

Hey!

I have an early version.
What a pleasure of being able to compile to flash, windows and android!
A lot faster than air on android.

https://github.com/chapatiz/smartfox-haxe-client

Pull requests are welcome.

Cheers

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 13 guests