Android Websocket issue

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

yagyesha
Posts: 5
Joined: 06 Jun 2013, 12:59

Android Websocket issue

Postby yagyesha » 07 Jun 2013, 06:29

We are developing a game using HTML5 technology for smartphone platform. Primarily the game should support iOS and Android platforms. Android does not provide web socket support currently. Though there are some open source implementation available but none of them work as is with SmartFoxServer 2X Javascript API. Here's the link to 2 implementations that we tried:

https://github.com/anismiles/websocket-android-phonegap
https://github.com/FreakDev/PhoneGap-An ... -WebSocket

Do you have any recommendations on this?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Android Websocket issue

Postby Lapo » 07 Jun 2013, 08:45

Yes, the state of websocket support under Android is a bit strange. Mostly because it depends on which browser is installed as default by the major carriers. Sadly the default Android browser does not support websockets but Chrome and Firefox do.
You could detect the browser in use and warn the user that they need either Chrome or Firefox to play.
Lapo
--
gotoAndPlay()
...addicted to flash games
yagyesha
Posts: 5
Joined: 06 Jun 2013, 12:59

Re: Android Websocket issue

Postby yagyesha » 18 Jun 2013, 12:16

Though it's an HTML5/Javascript app, we would bundle it in a native shell using frameworks like PhoneGap. So our application is not going to run directly on browser instead it would use the web view. Now with this information, what would you guys recommend?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Android Websocket issue

Postby Lapo » 18 Jun 2013, 12:44

But the web view is in fact an instance of the default browser renderer, I imagine.
In such case there's not much that can be done, because in essere you're running through those browser API which don't support websockets :(
Lapo

--

gotoAndPlay()

...addicted to flash games
yagyesha
Posts: 5
Joined: 06 Jun 2013, 12:59

Re: Android Websocket issue

Postby yagyesha » 20 Jun 2013, 10:33

Your replies are kind of making me nervous. At the moment, Android support for my app looks to be in the soup.
Have you had any experience with any of the open source Java implementation of Web sockets that's compatible with PhoneGap i.e.
https://github.com/anismiles/websocket-android-phonegap
https://github.com/FreakDev/PhoneGap-An ... -WebSocket

Has anyone tried these implementation to work with SmartFoxServer JS API?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Android Websocket issue

Postby Lapo » 20 Jun 2013, 13:03

I have no experience with phone gap nor the libraries you have mentioned.

If you're using HTML5 you are using our JS API, but you are not working with a browser directly, instead you are using web-view via Phonegap in which you add these Java client libraries. Not only but you are also supposed to use a specific javascript library that provides the glue between the Java side (phonegap) and the HTML5 side.

All this I have deduced from the docs, but you haven't explained anything about what you're doing. So how did you integrate the js component in our API?
If you want help you should at least explain what you're doing.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
yagyesha
Posts: 5
Joined: 06 Jun 2013, 12:59

Re: Android Websocket issue

Postby yagyesha » 21 Jun 2013, 09:57

You got it right with your understanding on how things would work with framework like PhoneGap. And that's exactly what i'm doing.
Both the links that i have mentioned provides the Java based implementation of WebSocket and the corresponding WebSocket.js file. Once this is configured in PhoneGap environment, WebSocket call from SFS Javascript API would first go to WebSocket.js and internally it would be delegated to Java implementation.
However, during runtime i get tons of 'undefined' errors for variables and functions from SFS Javascript API.
Hope this would give you clarity on what i'm doing.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Android Websocket issue

Postby Lapo » 21 Jun 2013, 10:22

Can you be more specific than that and provide details on which variables are reported as undefined?
Lapo

--

gotoAndPlay()

...addicted to flash games
FrankBov
Posts: 10
Joined: 06 Aug 2014, 17:59

Re: Android Websocket issue

Postby FrankBov » 13 Aug 2014, 15:45

For one of our projects we have the same issue. Even though newer Android phones support websockets, a large part of our target audience does not.
Unfortunately our budget does not have room to build seperate versions.

Our current approach is match the Java/Android library as a plugin with PhoneGap instead of just the websocket plugin as most websocket plugins are in beta or semi-complete.
We will keep you posted with our successes or failures. If you have any progress it would be nice to share this as well.
FrankBov
Posts: 10
Joined: 06 Aug 2014, 17:59

Re: Android Websocket issue

Postby FrankBov » 25 Aug 2014, 13:50

To help anyone. We successfully created a proof of concept in which we connected the Android API to Phonegap using the plugin system.
Now you know it works you should have no problem implementing this (if you have enough Phonegap/Smartfox) knowledge.

We tested it as far as connecting to the AdvancedChat and send a message which was received.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Android Websocket issue

Postby Lapo » 25 Aug 2014, 15:14

Thanks for posting and letting us know the results of your experiments.
Good to know that the integration is possible.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 18 guests