GithubHelp home page GithubHelp logo

HTML5 support ? about smartfox-haxe-client HOT 9 CLOSED

boorik avatar boorik commented on June 20, 2024
HTML5 support ?

from smartfox-haxe-client.

Comments (9)

boorik avatar boorik commented on June 20, 2024

Html5 target requires some work depending the features you want to use. But it's really easy to implement, you only have to create externs for the class you want. You can have a look at the "#if html5" part in https://github.com/boorik/smartfox-haxe-client/blob/master/com/smartfoxserver/v2/SmartFox.hx for a complex example. Some are really simplier like the LoginRequest.hx
Let me know if it make sense to you.

from smartfox-haxe-client.

rewb0rn avatar rewb0rn commented on June 20, 2024

Hi,

I would like to chime in, we are also looking forward to an HTML5 port for WebGL. Is it something you plan on doing or are you waiting for someone to help? We have no HTML5 / JS knowledge in our team but we will definitely need this feature soon.

Could it be an option to include the official SFS2X Javascript client API and just wrap it from Haxe for HTML5 targets?

Thanks in advance,
Ruben

from smartfox-haxe-client.

boorik avatar boorik commented on June 20, 2024

"Could it be an option to include the official SFS2X Javascript client API and just wrap it from Haxe for HTML5 targets?"

This is how it is currently working. Some externs are currently missing but has I said it's really easy to integrate them. You can try to add them if one that you need is missing. I can help you if you have issue to do so.

from smartfox-haxe-client.

rewb0rn avatar rewb0rn commented on June 20, 2024

Hi,

thanks for the clarification and your help! I have some compiler issues now when targeting HTML5 while the Flash target compiles without errors. It looks like the API is changing for HTML5 so that it can not easily be used crossplatform.

Here are some of the compiler errors I am seeing:

  • new SFSArray(): Not enough arguments, expected s:Array
  • SFSArray.newInstance(): com.smartfoxserver.v2.entities.data.SFSArray has no field newInstance
  • SmartFox.isConnected() is a function in HTML5, is a field in Flash
  • LoginRequest constructor parameters are different for HTML5
  • SmartFox.addEventListener() expects a new third parameter in HTML5
  • SmartFox does not implement IEventDispatcher in HTML5
  • SFSEvent does not extend Event in HTML5

So it looks like using the external JS API is causing some compatibility issues with the Flash API. I am very new to Haxe, but can the API be unified somehow? Otherwise how would you use the library for both Flash and HTML5 targets?

Thanks in advance,
Ruben

from smartfox-haxe-client.

boorik avatar boorik commented on June 20, 2024

Yes,
The JS api is not the same than flash api but it can be managed using compilation flags, you can have a look at this sample project : https://github.com/boorik/smartfox-haxe-fullstack
and particularly at this file : https://github.com/boorik/smartfox-haxe-fullstack/blob/js-1.7.5/client/src/SFSHandler.hx#L100
Look at the #if html5 statements. Hope it helps.

BTW the branches js-1.7.5 are more uptodate than master, use it with the last sfs version.
I will set the current master as legacy and js-1.7.5 as master in the next weeks.

Regards

from smartfox-haxe-client.

rewb0rn avatar rewb0rn commented on June 20, 2024

Hi,

thanks again! Looks like you are currently actively workin on the js-1.7.5 version, right? I updated my client to the js-1.7.5 branch and first got some compilation errors in HTML5: SFSRoomManager not found in SFSRoom.hx and SFSUserManager not found in SFSUser.hx. I could solve them by putting the imports on top. Also the SFSArray seems to have the wrong externs, it uses the same functions like SFSObject (i.e. putUtfString instead of addUtfString).

Do you think it would make more sense for me to wait until you are done migrating? I have no problem fixing the stuff myself as far as I can but it looks like you are working on that anyway.

Thanks, Ruben

from smartfox-haxe-client.

boorik avatar boorik commented on June 20, 2024

Sorry for the errors, i m away from keyboard for 2 days. You can make a pull request so i can integrate yourte fixes.

from smartfox-haxe-client.

rewb0rn avatar rewb0rn commented on June 20, 2024

Ok cool, I have created the pull request now.

from smartfox-haxe-client.

boorik avatar boorik commented on June 20, 2024

Merged!

from smartfox-haxe-client.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.