Check internet by appformative
Weiyu
Member Posts: 216
@Hopscotch Excuse me, I’m sorry to bother you.
I feel this discussion is so cool after I read this post.
http://forums.gamesalad.com/discussion/93486/check-if-there-is-internet-or-not
So I tried to make it which check internet with appformative, and I have gotten this data in my table.
But I have no idea, how to used this data to check connect internet or not?
Could you teach me that? thank you.
Comments
Just check the callback attribute; if it is set to 1 after you have run your Appformative code, then there is internet connection
@johnnymagne Thank you for answer.
But I'm sorry about that, I'm still not clear
Could you check whether my behaviour is correct or not?
Timer
Every 20 s
Network Get Table From URL
URL: game.get_servertime_URL .. game.AF_UserID
Table: T_Analytics
Callback Attribute: self.firstcontact
Rule (not in timer)
If "seld.firstcontact = 1"
Touch pressed and do change scene to "A"
@Weiyu
that will work, but your Timer should not be set to every 20s! That will drive the users data usage up and drain the battery. Checking once every few minutes is enough.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch I'm so glad you can answer my questions
Thank you for answer.
Then I have a little trouble, my callback attribute will loops repeated.(0→1, 1→0), when it every check. (This gif is 4 times speed)
Does callback attribute can fixed?
For example: If game connect to the internet, self.firstcontack will fixed value to 1 ,
( Unless the internet not connected, it can't changed the value to 0, when every check.)
@Weiyu
GS sets the callback to 0 when the network call gets made.
Ideally, have a separate attribute, e.g. isOnline. Then do the network call, and when the callback turns 1, set the isOnline attribute. If the callback does not turn 1 after a few seconds, assume they are not online and turn the isOnline attribute off.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch
This is a very helpful answer, thank you.
I appreciate your help.
Glad you solved it.!