Hi everybody,
Here’s my “problem” : i have an app that checks every 15 sec (for example) for new data.
I’m using a script originally written by Gilbert Guerrero, so here’s the code :
[lua]local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
tickerTimer = {}
– local file size
local original_size = 0
– data link
local data_url = “http://somewhere.com/here.xml”
local function checkNewData ()
local size2get = 0
local r, c, h = http.request {method = “HEAD”, url = data_url}
if c == 200 then
size2get = tonumber(h[“content-length”])
print( "Remote filesize : " … size2get )
connectionMade = true
else
print(“Error contacting remote host.”)
connectionMade = false
end
–compare the size of the files
if size2get ~= original_size and connectionMade then
local alert = native.showAlert( “New data !”, “yay !” )
original_size = size2get – Avoiding alert spam 
end
end
function startTicker ()
print(“ticker starts”)
tickerTimer = timer.performWithDelay(5000, checkNewData,0)
end
function pauseTicker ()
print(“ticker is paused”)
timer.pause(tickerTimer)
end
function resumeTicker ()
print(“ticker is resumed”)
timer.resume(tickerTimer)
end
startTicker ()[/lua]
So tickerTimer works in background while the app is running.
It works pretty well, except it slows, even freezes the app… (Even the simulator!!)
Do you think there’s a better way to do this ?
Thanks for reading ! 
(and i don’t want to use pubnub ) [import]uid: 3638 topic_id: 18017 reply_id: 318017[/import]
