1

Here is my network handler: https://gist.github.com/anonymous/22fc110ad126ef3a2c5f

The problem is that when data is received it blocks my animiation (I have a wheel spinning when data has been requested) so it looks like the app have crashed and then after 1 second or 2, when the data has been received, it works like a charm.

This line seems to make sure that when waiting for an answer the app doesn't freeze:

local input,output = socket.select( { self.sock }, nil, 0 ) -- this is a way not to block runtime while reading socket. zero timeout does the trick

Here is another timeout setting:

 self.sock:settimeout(0)

I have tried to change them to 0.01 and 0.001 but with no luck. I'm not really sure how to make it so the animation doesn't freeze.

Maybe I should change to one of Coronas built in async network handler (with callback functions) or is it possible to modify this network handler so that the animation doesn't freeze?

greatwolf
  • 20,287
  • 13
  • 71
  • 105
Westerlund.io
  • 2,743
  • 5
  • 30
  • 37

1 Answers1

0

If you can use Corona's network.* api, it's async so you won't have any blocking calls.

Documentation link: http://docs.coronalabs.com/daily/api/library/network/index.html

PersuitOfPerfection
  • 1,009
  • 1
  • 15
  • 28