I’m using appodeal. The problem is this if the user starts the game with the active conection and then turns it off. When I need publicity I do something like:
if( appodeal.isLoaded("interstitial") ) then appodeal.show( "interstitial" ) startAds = true else startAds = false end
This imposes a “startAds” equal to the true but in reality having the connition turned off the publicity will not be shown.
This is a problem because I perform several operations if startAds = true.
I could conquer the connection from time to time but this causes some slowdowns.
Is there another fluid way?
To verify the connection I do:
function M.checksInternetConnection() local socket = require("socket") local test = socket.tcp() test:settimeout(1000) -- Set timeout to 1 second local testResult = test:connect("www.google.com", 80) local thereIs if not(testResult == nil) then print("Internet access is available") thereIs = true else print("Internet access is not available") thereIs = false end test:close() test = nil return thereIs end