I have been testing with Corona Cloud and have been getting back multiple hits to the event listener for one call to the coronaCloud API… So for example I use createMatch() to create a single match, but the event handler is firing twice. deleteMatch and getMatches seems to do the same thing and the number of hits to the event handler seems pretty random… Sometimes its once, sometimes its two or three times. Is this the expected behavior? Any suggestions for a work around that is not ugly? Or is my code just messed up?
Code:
functions
function newGame(challengeType,player2UserID) coronaCloud.createMatch() Runtime:addEventListener( "Multiplayer", multiPlayerHandler ) end function getGames() coronaCloud.getMatches() Runtime:addEventListener( "Multiplayer", multiPlayerHandler ) end function deleteGame(matchID) print(" Delete Match Called:"..matchID) coronaCloud.deleteMatch(matchID) Runtime:addEventListener( "MatchDeleted", multiPlayerHandler ) end
handler for all three functions:
local function multiPlayerHandler( event ) print("Entered the multiPlayer Handler") if event.type == "MatchCreated" then print("Match Created") elseif event.type == "Matches" then print(" Received Matches") games = event.results loadNewGameList() print("Game List Done") elseif event.type == "MatchDeleted" then getGames() print("Match Deleted") end return true end
Thanks,
Mike