Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML5 support ? #2

Closed
flashultra opened this issue Jul 11, 2017 · 9 comments
Closed

HTML5 support ? #2

flashultra opened this issue Jul 11, 2017 · 9 comments

Comments

@flashultra
Copy link
Contributor

Hi ,
Is HTML5 support still in progress ? What is the current status of the html5 target?

@boorik
Copy link
Owner

boorik commented Jul 11, 2017

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.

@rewb0rn
Copy link

rewb0rn commented Aug 16, 2017

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

@boorik
Copy link
Owner

boorik commented Aug 16, 2017

"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.

@rewb0rn
Copy link

rewb0rn commented Aug 19, 2017

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

@boorik
Copy link
Owner

boorik commented Aug 19, 2017

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

@rewb0rn
Copy link

rewb0rn commented Aug 19, 2017

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

@boorik
Copy link
Owner

boorik commented Aug 19, 2017

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

@rewb0rn
Copy link

rewb0rn commented Aug 20, 2017

Ok cool, I have created the pull request now.

@boorik
Copy link
Owner

boorik commented Aug 20, 2017

Merged!

@boorik boorik closed this as completed Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants