net.NetworkTester Extends
Creates an instance of goog.net.NetworkTester which can be used to test for internet connectivity by seeing if an image can be loaded from google.com. It can also be tested with other URLs.

Inheritance

Constructor

goog.net.NetworkTester(callbackopt_handleropt_uri)

Parameters

callback : Function
Callback that is called when the test completes. The callback takes a single boolean parameter. True indicates the URL was reachable, false indicates it wasn't.
opt_handler : Object=
Handler object for the callback.
opt_uri : goog.Uri=
URI to use for testing.

Instance Methods

Public Protected Private
cleanupCallbacks_()
Cleans up the handlers and timer associated with the image.
code »
getNumRetries() number
Returns the numer of retries to attempt.
Returns: number  Number of retries to attempt.
code »
getPauseBetweenRetries() number
Returns the pause between retries in milliseconds.
Returns: number  Pause between retries in milliseconds.
code »
getTimeout() number
Returns the timeout in milliseconds.
Returns: number  Timeout in milliseconds.
code »
getUri() goog.Uri
Returns the uri to use for the test.
Returns: goog.Uri  The uri for the test.
code »
isRunning() boolean
Returns whether the tester is currently running.
Returns: boolean  True if it's running, false if it's not running.
code »
onImageAbort_()
Callback for the image load being aborted.
code »
onImageError_()
Callback for the image failing to load.
code »
onImageLoad_()
Callback for the image successfully loading.
code »
onImageTimeout_()
Callback for the image load timing out.
code »
onPauseFinished_()
Callback for the pause between retry timer.
code »
onResult(succeeded)
Handles a successful or failed result.
Arguments:
succeeded : boolean
Whether the image load succeeded.
code »
setNumRetries(retries)
Sets the timeout in milliseconds.
Arguments:
retries : number
Number of retries to attempt.
code »
setPauseBetweenRetries(pauseMs)
Sets the pause between retries in milliseconds.
Arguments:
pauseMs : number
Pause between retries in milliseconds.
code »
setTimeout(timeoutMs)
Sets the timeout in milliseconds.
Arguments:
timeoutMs : number
Timeout in milliseconds.
code »
setUri(uri)
Sets the uri to use for the test.
Arguments:
uri : goog.Uri
The uri for the test.
code »
start()
Starts the process of testing the network.
code »
startNextAttempt_()
Starts the next attempt to load an image.
code »
stop()
Stops the testing of the network. This is a noop if not running.
code »

Instance Properties

attempt_ :
Attempt number we're on
Code »
callback_ :
Callback that is called when the test completes. The callback takes a single boolean parameter. True indicates the URL was reachable, false indicates it wasn't.
Code »
handler_ :
Handler object for the callback.
Code »
logger_ : goog.debug.Logger
Logger object
Code »
pauseBetweenRetriesMs_ :
Pause between retries in milliseconds.
Code »
pauseTimer_ :
Timer for pauses between retries.
Code »
retries_ :
Number of retries to attempt
Code »
running_ :
Whether we've already started running.
Code »
timeoutMs_ :
Timeout for test
Code »
timeoutTimer_ :
Timer for timeouts.
Code »
uri_ : goog.Uri
Uri to use for test. Defaults to using an image off of google.com
Code »

Static Methods

goog.net.NetworkTester.getNavigatorOffline_() boolean
No description.
Returns: boolean  Whether navigator.onLine returns false.
code »

Static Properties

goog.net.NetworkTester.DEFAULT_TIMEOUT_MS :
Default timeout
Code »

Package net

Package Reference