Open dereulenspiegel opened 11 years ago
Hi, can you elaborate? wAsync is fully asynchronous, hence I needed to add those android property. How can it be avoided?
On newer versions of Android there is a policy which prohibits all network activity on the UI thread. In case you call any method related to networking like opening sockets or using URLConnection.open an exception is thrown. It seems that wAsync does some networking on Socket.open before everything else is handled in the background. On other platforms this might not be a problem, but Android is very strict with these things. Threading in general is a bit tricky, since the results must be delivered back to the UI on the UI thread. In the long run it could be nice for developers to have some kind of "wrapper" for wAsync on Android which handles threading and delivery of results in the correct threads.
I see. If you have the cycle, do a pull request with your idea and I will start from there.
When creating a connection in Android activities in onCreate (like shown here http://jfarcand.wordpress.com/2013/04/04/wasync-websockets-with-fallbacks-transports-for-android-node-js-and-atmosphere/) the exception android.os.NetworkOnMainThreadException is thrown. wasync seems to invoke networking methods not on in a background thread. While it is possible and trivial to do the connection set up in the background the expectation is that an synchronous librarylike wasync does all networking in a background thread. This would simplify the usage of this library.