The goog.net.NetworkTester Class

goog.net.NetworkTester(callback, opt_handler, opt_uri)

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.

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.

.DEFAULT_TIMEOUT_MS {number}

Default timeout

.getNumRetries()

Returns the numer of retries to attempt.

returns {number}
Number of retries to attempt.

.getPauseBetweenRetries()

Returns the pause between retries in milliseconds.

returns {number}
Pause between retries in milliseconds.

.getTimeout()

Returns the timeout in milliseconds.

returns {number}
Timeout in milliseconds.

.getUri()

Returns the uri to use for the test.

returns {goog.Uri}
The uri for the test.

.isRunning()

Returns whether the tester is currently running.

returns {boolean}
True if it's running, false if it's not running.

.onResult(succeeded)

Handles a successful or failed result.

succeeded {boolean}
Whether the image load succeeded.

.setNumRetries(retries)

Sets the timeout in milliseconds.

retries {number}
Number of retries to attempt.

.setPauseBetweenRetries(pauseMs)

Sets the pause between retries in milliseconds.

pauseMs {number}
Pause between retries in milliseconds.

.setTimeout(timeoutMs)

Sets the timeout in milliseconds.

timeoutMs {number}
Timeout in milliseconds.

.setUri(uri)

Sets the uri to use for the test.

uri {goog.Uri}
The uri for the test.

.start()

Starts the process of testing the network.

.stop()

Stops the testing of the network. This is a noop if not running.