Mobile Check Bandwidth Function

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
Can  anyone share their "test bandwidth" library?

I'm looking for both

1) this phone is off line
    --easy enough… ping your server, no response, = off line

2) check for bandwidth speed below some threshold and then inform  user
   -- be patient, your internet speed is slow, this may take time.

anyone already invent this wheel yet?

BR
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
I’m also very interested in this.

I’m thinking that it might be possible to use a LC-only method:
1. A player control starts downloading a known-size media file.

2. The player reports when its <status> is no longer “loading,” then you calculate the data rate based on the elapsed time.
(In LC for Windows only, the player has a loadedTime property with which one could presumably calculate data rate.)

3. Possibly another method would be to set the callbacks of the player, such as one callback every 500 milliseconds. You would use a timer to figure how long it takes to receive each callback. If they are arriving every half second for a large file, then the speed needle would move the “Good” range. If the download is slow, the callbacks would be late, and the needle would move to the “you must be a rural Internet customer” area.

This kind of thing would require a “speed test” event before the results could be reported to the user.

Creating/testing this might be a challenge if you happen to have a good connection. You would have to somehow slow down your speed, or have someone else test it who does have a slow connection. Also, after loading a file, LC keeps it in a cache unless you dump it.

Peter Bogdanoff




On Jul 2, 2017, at 6:53 PM, Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:

> Can  anyone share their "test bandwidth" library?
>
> I'm looking for both
>
> 1) this phone is off line
>    --easy enough… ping your server, no response, = off line
>
> 2) check for bandwidth speed below some threshold and then inform  user
>   -- be patient, your internet speed is slow, this may take time.
>
> anyone already invent this wheel yet?
>
> BR
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
Good thoughts,

Spotify actually will inform you that you don't have a connection even if you have 3G up..  

I would like to know how they do that.. because my app *can* ping our server over 3G… but Spotify deems the connection  insufficient to stream music and displays the "disconnected" icon.  So this goes to the speed testing you are looking for..

 I suspect another issue. I won't know for sure until I test tomorrow. But the mere act of "fishing on the internet" may hang the OS on mobile.

ergo.. on desktop this works

function pingServer
   # call from any where to inform user and disable activities
   # that require internet access to our server or any the external service
   put url "https://www.himalayanacademy.com/ping.txt" into sOnlineStatus
   return sOnlineStatus
end pingServer

and if I unplug ethernet and turn off wifi  I can run from the msg box "put pingServer()" and not happens.. just returns empty

but my current behavior (still to be sorted) indicates that just try to fetch a URL, without a connection causes my app to hang.

I only discovered this serendipitously when the local router in our neighborhood suddenly started having trouble. We thought it was local to our LAN-place but the ISP in town said "People all over that area are complaining, their internet dropping on and off." of course has to happen on 4th July weekend (hehe)

My phone was connected to the local wifi→ to our modem → out the door down the street the "regional" router.  I was trying to show off my app and it would just hang on modules that expecting connectivity. but I *did* have my ping test functional.

I have similar/parallel issues with in house apps that test to see if the LAN network is up or not. You can do peculiar things that cause Apple's network API to stop and think for 2 minutes!

Leads to 2 further questions

1) is there a low level check on iOS/Android for connectivity that we can use vs calling out to our server? Some people use Google DNS servers for this test, but it would be *any* http request.
  -- I looked  through all dictionary entries for "mobile*" and found nothing relevant, though possibly there is some sensor we can query?
2) anyone know how to turn off connectivity, on your phone, even if you have your sim card in? I'm not finding a way to actually turn off LTE or 3G access.
  -- I missing something simple there… on my Nexus 5  I don't have a SIM card (used only for testing, no cellular or data plan) but I can do everything if I am in proximity of our wifi, so for android I can just turn off wifi and the phone is "off line" for sure, but iOS?


BR


 

On 7/2/17, 4:44 PM, "use-livecode on behalf of Peter Bogdanoff via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:

    I’m also very interested in this.
   
    I’m thinking that it might be possible to use a LC-only method:
    1. A player control starts downloading a known-size media file.
   
    2. The player reports when its <status> is no longer “loading,” then you calculate the data rate based on the elapsed time.
    (In LC for Windows only, the player has a loadedTime property with which one could presumably calculate data rate.)
   
    3. Possibly another method would be to set the callbacks of the player, such as one callback every 500 milliseconds. You would use a timer to figure how long it takes to receive each callback. If they are arriving every half second for a large file, then the speed needle would move the “Good” range. If the download is slow, the callbacks would be late, and the needle would move to the “you must be a rural Internet customer” area.
   
    This kind of thing would require a “speed test” event before the results could be reported to the user.
   
    Creating/testing this might be a challenge if you happen to have a good connection. You would have to somehow slow down your speed, or have someone else test it who does have a slow connection. Also, after loading a file, LC keeps it in a cache unless you dump it.
   
    Peter Bogdanoff
   
   

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In iOS, Settings/Cellular/Cellular Data there is on/off switch.

pb

On Jul 2, 2017, at 9:16 PM, Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:

> Good thoughts,
>
> Spotify actually will inform you that you don't have a connection even if you have 3G up..  
>
> I would like to know how they do that.. because my app *can* ping our server over 3G… but Spotify deems the connection  insufficient to stream music and displays the "disconnected" icon.  So this goes to the speed testing you are looking for..
>
> I suspect another issue. I won't know for sure until I test tomorrow. But the mere act of "fishing on the internet" may hang the OS on mobile.
>
> ergo.. on desktop this works
>
> function pingServer
>   # call from any where to inform user and disable activities
>   # that require internet access to our server or any the external service
>   put url "https://www.himalayanacademy.com/ping.txt" into sOnlineStatus
>   return sOnlineStatus
> end pingServer
>
> and if I unplug ethernet and turn off wifi  I can run from the msg box "put pingServer()" and not happens.. just returns empty
>
> but my current behavior (still to be sorted) indicates that just try to fetch a URL, without a connection causes my app to hang.
>
> I only discovered this serendipitously when the local router in our neighborhood suddenly started having trouble. We thought it was local to our LAN-place but the ISP in town said "People all over that area are complaining, their internet dropping on and off." of course has to happen on 4th July weekend (hehe)
>
> My phone was connected to the local wifi→ to our modem → out the door down the street the "regional" router.  I was trying to show off my app and it would just hang on modules that expecting connectivity. but I *did* have my ping test functional.
>
> I have similar/parallel issues with in house apps that test to see if the LAN network is up or not. You can do peculiar things that cause Apple's network API to stop and think for 2 minutes!
>
> Leads to 2 further questions
>
> 1) is there a low level check on iOS/Android for connectivity that we can use vs calling out to our server? Some people use Google DNS servers for this test, but it would be *any* http request.
>  -- I looked  through all dictionary entries for "mobile*" and found nothing relevant, though possibly there is some sensor we can query?
> 2) anyone know how to turn off connectivity, on your phone, even if you have your sim card in? I'm not finding a way to actually turn off LTE or 3G access.
>  -- I missing something simple there… on my Nexus 5  I don't have a SIM card (used only for testing, no cellular or data plan) but I can do everything if I am in proximity of our wifi, so for android I can just turn off wifi and the phone is "off line" for sure, but iOS?
>
>
> BR
>
>
>
>
> On 7/2/17, 4:44 PM, "use-livecode on behalf of Peter Bogdanoff via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:
>
>    I’m also very interested in this.
>
>    I’m thinking that it might be possible to use a LC-only method:
>    1. A player control starts downloading a known-size media file.
>
>    2. The player reports when its <status> is no longer “loading,” then you calculate the data rate based on the elapsed time.
>    (In LC for Windows only, the player has a loadedTime property with which one could presumably calculate data rate.)
>
>    3. Possibly another method would be to set the callbacks of the player, such as one callback every 500 milliseconds. You would use a timer to figure how long it takes to receive each callback. If they are arriving every half second for a large file, then the speed needle would move the “Good” range. If the download is slow, the callbacks would be late, and the needle would move to the “you must be a rural Internet customer” area.
>
>    This kind of thing would require a “speed test” event before the results could be reported to the user.
>
>    Creating/testing this might be a challenge if you happen to have a good connection. You would have to somehow slow down your speed, or have someone else test it who does have a slow connection. Also, after loading a file, LC keeps it in a cache unless you dump it.
>
>    Peter Bogdanoff
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

axwald
In reply to this post by Mark Waddingham via use-livecode
Hi.
Peter Bogdanoff via use-livecode wrote
Can anyone share their "test bandwidth" library?
Found it difficult & time consuming to test the actual bandwidth, so I'm testing the latency now. Bad latency usually relates to bad bandwidth ;-)

On my server I have a php script:
-------------------------------------
<?PHP
function getUserIP()  // 'myip.php' -- service script; don't change!
{
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];

    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        $ip = $client;
    }
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
    {
        $ip = $forward;
    }
    else
    {
        $ip = $remote;
    }
    return $ip;
}
$user_ip = getUserIP();
echo $user_ip; // Output IP address [Ex: 177.87.193.134]
?>
-------------------------------------

And in LC I use this function:
-------------------------------------
function INTest full
   put "http://myServer.net/tools/myip.php" into myIPURL
   if full then
      put the millisecs into t1
      put url myIPURL into myIP
      put the millisecs - t1 into t2
      return myIP & CR & t2
   else
      return url myIPURL
   end if
end INTest
-------------------------------------

Calling INTest() gives empty if we have no IN, else the actual public IP as seen from the server (often useful anyways). Calling INTest(true) additionally gives the latency on line 2.

Since this is small and not intrusive at all I can call it quite often to monitor IN quality even on mobile.

Have fun!

axwald
• Livecode programming until the cat hits the fan •
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
Peter Bogdanoff wrote:
 > Can anyone share their "test bandwidth" library?

I could have sworn there was a message named something like
networkConnetionChanged or mobileNetworkChanged or
mobileNetworkInterfaceChanged or whatever, but searching through the
Dictionary for every part of that I can think of turned up nothing.

Was I imagining this? If not, what is it's actual name, and would be
useful here?

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Ping will not work. Some firewalls will prevent ICMP packets to and or from a source. If this library is to be used universally, you need a better method to determine if a device is responding on a known port.

The tried and true method for doing this is telnet. Unfortunately, Microsoft decided NOT to enable the telnet client on Windows 8 and above. It has to be enabled by an end user. If you can create your own telnet stack, then it's doable.

telnet <ipaddress> <portnumber>

check the result.

Bob S


> On Jul 2, 2017, at 18:53 , Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
>
> Can  anyone share their "test bandwidth" library?
>
> I'm looking for both
>
> 1) this phone is off line
>    --easy enough… ping your server, no response, = off line
>
> 2) check for bandwidth speed below some threshold and then inform  user
>   -- be patient, your internet speed is slow, this may take time.
>
> anyone already invent this wheel yet?
>
> BR

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
reachabilityChanged (for iOS only???)

Bob S


> On Jul 3, 2017, at 07:48 , Richard Gaskin via use-livecode <[hidden email]> wrote:
>
> I could have sworn there was a message named something like networkConnetionChanged or mobileNetworkChanged or mobileNetworkInterfaceChanged or whatever, but searching through the Dictionary for every part of that I can think of turned up nothing.
>
> Was I imagining this? If not, what is it's actual name, and would be useful here?
>
> --
> Richard Gaskin


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Here is where a C applet would come in handy. Is it possible to have a C applet running that would be able to tell the LC engine that the network had changed? Otherwise, it would be REALLY USEFUL for a database application to "know" this.

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Bob Sneidar wrote:

 >> On Jul 3, 2017, at 07:48 , Richard Gaskin wrote:
 >>
 >> I could have sworn there was a message named something like
 >> networkConnetionChanged or mobileNetworkChanged or
 >> mobileNetworkInterfaceChanged or whatever, but searching through
 >> the Dictionary for every part of that I can think of turned up
 >> nothing.
 >>
 >> Was I imagining this? If not, what is it's actual name, and would
 >> be useful here?
 >
 > reachabilityChanged (for iOS only???)

Thanks.

"reachability"?  Whiskey Tango Foxtrot?  I'd love to hear the backstory
on that name choice.  It has the scent of things like "srcBic", adopted
from the arbitrary choices of neckbeards who define OS APIs.  Maybe
there's an API for iOS called NSReachabilityChanged.

If nothing else it's perhaps the most truly English-like token in the
language, steeped as it is in vague ambiguity just like so much in
natural languages. ;)

And iOS only?  What do we do for the other 80% of the world?

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
+5

> On Jul 3, 2017, at 09:35 , Richard Gaskin via use-livecode <[hidden email]> wrote:
>
> Thanks.
>
> "reachability"?  Whiskey Tango Foxtrot?  I'd love to hear the backstory on that name choice.  It has the scent of things like "srcBic", adopted from the arbitrary choices of neckbeards who define OS APIs.  Maybe there's an API for iOS called NSReachabilityChanged.
>
> If nothing else it's perhaps the most truly English-like token in the language, steeped as it is in vague ambiguity just like so much in natural languages. ;)
>
> And iOS only?  What do we do for the other 80% of the world?
>
> --
> Richard Gaskin


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
On 07/03/2017 09:35 AM, Richard Gaskin via use-livecode wrote:

> "reachability"?  Whiskey Tango Foxtrot?  I'd love to hear the backstory
> on that name choice.  It has the scent of things like "srcBic", adopted
> from the arbitrary choices of neckbeards who define OS APIs.  Maybe
> there's an API for iOS called NSReachabilityChanged.

Well, you've got Apple to blame for that one.
https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html

>
> If nothing else it's perhaps the most truly English-like token in the
> language, steeped as it is in vague ambiguity just like so much in
> natural languages. ;)

There are various interpretations of 'reachability' for iOS:

"Of course, Apple knows that many iPhone users want the option to
perform many functions with one hand, so it created a nifty little
feature called “Reachability.”"

https://bgr.com/2014/09/22/iphone-6-apple-features-iphone-6-plus/

According to the dictionary there are three LC functions here:
reachabilityChanged, iphoneReachabilityTarget, and
iphoneSetReachabilityTarget. I assume this "iphone" nomenclature is
what's known as painting yourself into a corner.

>
> And iOS only?  What do we do for the other 80% of the world?
>

Android:
https://developer.android.com/reference/android/net/ConnectivityManager.html

--
  Mark Wieder
  [hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
Mark Wieder wrote:

 > On 07/03/2017 09:35 AM, Richard Gaskin via use-livecode wrote:
 >
 >> "reachability"?  Whiskey Tango Foxtrot?  I'd love to hear the
 >> backstory on that name choice.  It has the scent of things like
 >> "srcBic", adopted from the arbitrary choices of neckbeards who
 >> define OS APIs.  Maybe there's an API for iOS called
 >> NSReachabilityChanged.
 >
 > Well, you've got Apple to blame for that one.
 >
https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html


Did I call or it did I call it? :)  Seems my nose for nomenclature has
gotten pretty good over the decades.  Like bears with sandwiches, I can
smell an Apple API name at 400 yards. :)


 >> And iOS only?  What do we do for the other 80% of the world?
 >
 > Android:
 >
https://developer.android.com/reference/android/net/ConnectivityManager.html

I figured there was a parallel API for Android.  I guess my question was
when we might see feature completion on the script access for that in LC.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
On 07/03/2017 01:50 PM, Richard Gaskin via use-livecode wrote:

> I figured there was a parallel API for Android.  I guess my question was
> when we might see feature completion on the script access for that in LC.
>

...and thus my snarky comment about the "iphone<whatever>" naming.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode

> On 4 Jul 2017, at 6:50 am, Richard Gaskin via use-livecode <[hidden email]> wrote:
>
> >> And iOS only?  What do we do for the other 80% of the world?
> >
> > Android:
> > https://developer.android.com/reference/android/net/ConnectivityManager.html <https://developer.android.com/reference/android/net/ConnectivityManager.html>
>
> I figured there was a parallel API for Android.  I guess my question was when we might see feature completion on the script access for that in LC.


Actually we have access to basically anything you want on Android now via LCB and now that that’s the case if we provided an API for it we would do it via LCB too. I’m sure Ali could wrap it pretty quickly but it might be a good idea for the community to take it on and give us some feedback on our docs. The sooner people start wrapping and sharing code for system APIs the better.
 
https://livecode.com/using-infinite-livecode-for-android-to-create-native-controls-and-wrap-os-apis/ <https://livecode.com/using-infinite-livecode-for-android-to-create-native-controls-and-wrap-os-apis/>

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
OK I'm back.. sheesh… Spectrum purchase Time Warner Cable for some Ka
bilion dollars and they run our show here now… but it took them four days to figure out that a splice in a wire between our main modem for the enterprise and the router on the street that was  probably filling up with water everytime it rains here (which is frequent this week.)

But it was a good time to be "up and down" on the internet as I had no choice but to focus on my connectivity scripts.  So this does go so far as giving us a bandwidth value, but I think I have a solution for the "reachability" thing..

Using LTE on my iPhone read all this business in Apple's Docs on "reachability" but even apple is using a ping to www.appleiphonecell.com  which returns the word "success". But our problem is

on pingServer
  put url https://www.himalayanacademy.com/ping.txt" into sOneLineStatus # the file contains one word "true"
end pingServer

Is blocking… on the desktop took sometimes 3 minutes (Yeah.. no kidding) for Livecode to step through that line and return "empty")
on mobile the app will just hang… but the I had this "ahha!" moment where I thought "Duh, Scott Raney solved this 20 years ago" (really been that long?)

one never knows how much one has forgotten… years ago I did preload media and I thought

"Wait! What about LOAD… URL Status…. these are none blocking"

So with the connection up and down I went about cooking up what I think is a low-level solution.
disclaimer: I don't know what I'm doing and there is always a better way.

This is a text only library that is put into use on start up… after start up we send
 off

 connectivity_PingServer  in 500 milliseconds

after the UI is finished loading


Local sPingURL,sServerAttempts # sURLStatusLog

on connectivity_PingServer
  # may have been cached before' but connectivity died so we need to do this first:
# just in case….
   unload URL "https://www.himalayanacademy.com/ping.txt"
  put 0 into sServerAttempts
   # Logging: put empty into sURLStatusLog
   put "https://www.himalayanacademy.com/ping.txt" into sPingURL
   load url sPingURL
   dispatch "connectivity_UpdateStatus" to me
end connectivity_PingServer

on connectivity_UpdateStatus
   if URLStatus(sPingURL) = "cached" then
      put "true" into sOnLinestatus
      put 0 into sServerAttempts
# that's it nothing more to do…
   else
      put URLStatus(sPingURL)  into tURLStatus
      if (sServerAttempts > 10) and URLStatus(sPingURL)<> "cached" then
         put tURLStatus into sOnLinestatus
         dialog_CustomMsg true,"Offline or Low Bandwidth", 1500      
   
   # keep checking but don't hog the CPU...
         put 0 into sServerAttempts # start over again
         send connectivity_PingServer to me in 10  seconds
      else
         # Logging
         --       put URLStatus(sPingURL) & cr after sURLStatusLog
         --       put sURLStatusLog
         add 1 to sServerAttempts
          dialog_CustomMsg true,"Connecting", 800    
         send connectivity_UpdateStatus to me in 800 milliseconds
      end if
   end if
end connectivity_UpdateStatus

# Use this in the module so we don't ping the server constantly.

function connectivity_GetStatus
   return sOnLineStatus
end connectivity_GetStatus

This is working on desktop and mobile

Any refinements you wizards can offer will be appreciated.

I'm off to dig up an old library that Scott Raney had that I believe monitors download progress. and I bet playing around with this you could get a bandwidth value in a very "primitive" way by just downloading a small file and measure the time?

BR






    > On 07/03/2017 09:35 AM, Richard Gaskin via use-livecode wrote:
    >
    >> "reachability"?  Whiskey Tango Foxtrot?  I'd love to hear the
    >> backstory on that name choice.  It has the scent of things like
    >> "srcBic", adopted from the arbitrary choices of neckbeards who
    >> define OS APIs.  Maybe there's an API for iOS called
    >> NSReachabilityChanged.
    >
    > Well, you've got Apple to blame for that one.



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
I am getting a reply right away. But this is interesting. I wonder if a similar call can be made to a SQL server? Just knowing I have an internet connection is not enough. I need to know if the SQL server is visible. I also need to know when the network has changed as I reauthenticate when the database connection disappears.

Bob S


> On Jul 4, 2017, at 10:56 , Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
>
> on pingServer
>  put url https://www.himalayanacademy.com/ping.txt" into sOneLineStatus # the file contains one word "true"
> end pingServer
>
> Is blocking… on the desktop took sometimes 3 minutes (Yeah.. no kidding) for Livecode to step through that line and return "empty")
> on mobile the app will just hang… but the I had this "ahha!" moment where I thought "Duh, Scott Raney solved this 20 years ago" (really been that long?)

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
I am missing something. This only returns the string sOnLineStatus. And yes I copied all the script for the other handlers. :-)

Bob S


> On Jul 4, 2017, at 10:56 , Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
>
> function connectivity_GetStatus
>   return sOnLineStatus
> end connectivity_GetStatus


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mobile Check Bandwidth Function

Mark Waddingham via use-livecode
I ran connectivity_PingServer in the message box using do. I am missing the handler dialog_CustomMsg

Bob S




> On Jul 5, 2017, at 08:08 , Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> I am missing something. This only returns the string sOnLineStatus. And yes I copied all the script for the other handlers. :-)
>
> Bob S


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...