My app is polling a UDP socket, which I’m trying to thread with a coroutine. Everything works fine until director changes scenes, then the coroutine goes to “dead” status. Am I missing something basic?
Here is my main.lua where I set up the coroutine. The MessagePump module reads the UDP socket and returns a list of packets read. I can see the print(packet.debug()) output until the scene changes.
[code]
local rkThread = nil
local function crankPump(event)
coroutine.resume(rkThread)
end
local function main()
MessagePump.new() – init socket and packet factory
rkThread = coroutine.create(
function()
while true do
local pktlist = MessagePump.readall()
for _,packet in pairs(pktlist) do
print(packet.debug)
packet:updateState()
end
coroutine.yield()
end
end
)
Runtime:addEventListener(“enterFrame”, crankPump)
mainGroup:insert(director.directorView)
director:changeScene(“SplashScene”, “fade”)
return true
end
main() [import]uid: 58455 topic_id: 24031 reply_id: 324031[/import]