Class

device/AbstractNetwork

device/AbstractNetwork()

Constructor

# new device/AbstractNetwork()

Base Network class that should be inherited by all device specific Network implementation.

Members

base/ConnectionPoller

# protected _internetPoller

Private reference to XDK's own AJAX ConnectionPoller instance. This reference will only be set on platforms where no native internet, not network, connection check is available.

# protected _networkType

Network type enumerator.

Methods

# protected _isInternetConnected() → {Boolean|Promise}

This protected function is used to wrap any logic that is used to check if the browser is connected to the internet or not.

This function should not be called directly by other module.

The function should either return a pure boolean or promised-wrapped boolean value, depending on the device specific implementation.

The implementation provided by this AbstractNetwork module will return true regardlessly if ConnectionPoller is not initialised and will return the result of the function ConnectionPoller#isConnected if the poller is initialised.

Module derived from AbstractNetwork should override this function if other internet connectivity check is used.

Return true, if the device is believed to be connected to the internet. The value can be wrapped by a Promise if the result is returned asynchronously.

Boolean | Promise

# deinitConnectionPoller()

Stop the internet connection poller, and remove its reference.

# getNetworkStatus() → {Promise.<Boolean>}

Return whether the browser is connected to the internet or not.

The result returned will be the last known connection status. The freshness of this value depends on the polling interval. If XDK ConnectionPoller is used, the polling interval can be tuned. If device's native implementation is used, then the polling interval depends on the native implementation.

The result is wrapped within a Promise to harmonise the different implementations of connectivity check on different platforms, which some of those is synchronous, and others asynchronous.

Promise.

Promise.<Boolean>

# getSignalStrength() → {Promise.<*>}

Return the WiFi signal strength reported by the system, wrapped by a promise. The value type of the signal strength can varies. It can be a number or string or anything manufacturer deems fit.

Promise. Default to return the string 'dummySignalStrength'.

Promise.<*>

# initConnectionPoller()

Create the internet poller instance if it is not already created. The poller, however, will be in a stopped state. The user, most likely the derived Network module, is responsible to start the polling by calling startPolling.

This function was previously called __checkNetworkStatus.

See:
  • startPolling

# startPolling()

Command the poller, if initialised, to start polling of connection to internet.

See:
  • initConnectionPoller

# stopPolling()

Command the poller, if initialised, to stop polling of connection to internet.

See:
  • deinitConnectionPoller