Skip to main content
ConnectivityTask runs RunConnectivityTask as a persistent worker thread. It pings the active server every 10 seconds and updates m.global.hasInternet and m.global.isOnline. The task can also be triggered to check immediately via the checkNow input field.
This task runs for the entire lifetime of the channel. Stop it only by setting control = "stop" when the channel is closing.

XML component definition

ConnectivityTask.xml
<?xml version="1.0" encoding="utf-8" ?>
<component name="ConnectivityTask" extends="Task">
  <interface>
    <!-- output -->
    <field id="hasInternet" type="boolean" value="true" />
    <!-- input/trigger -->
    <field id="checkNow"    type="boolean" value="false" />
  </interface>
  <task functionName="RunConnectivityTask" />
</component>

Input fields

checkNow
Boolean
Toggle to true to trigger an immediate connectivity check outside the normal 10-second cycle. The task resets the field to false after the check completes.

Output fields

hasInternet
Boolean
Updated after every check. true when GTV_PingServer() succeeds against the active server; false otherwise. The same value is mirrored to m.global.hasInternet.

Global state written

In addition to the hasInternet field, the task updates two global fields directly:
Global fieldDescription
m.global.hasInternetMirror of the hasInternet output field
m.global.isOnlineResult of GTV_IsOnline() (roDeviceInfo.GetConnectionType() check)

Function flow

1

Initial check

DoCheck() is called once before the wait loop starts so that connectivity state is available immediately.
2

Wait loop

Waits up to 10 000 ms on a message port that observes checkNow and control.
3

Handle control messages

If checkNow fires, runs DoCheck() immediately and resets the field. If control = "stop", the task returns.
4

Scheduled check

When the wait times out (no message received), DoCheck() runs for the scheduled interval tick.
5

DoCheck

Resolves the server URL from m.global.activeServer via GTV_ServerNormalizeBaseUrl(). Falls back to GTV_ServerPrimaryConnectivityUrl() if no active server is set. Calls GTV_PingServer(server) and writes the boolean result to m.top.hasInternet, m.global.hasInternet, and m.global.isOnline.
6

State-change logging

Only logs when the connectivity state changes (onlineofflinemissing_server) to avoid flooding the log with repeated entries.

Usage example

' Start connectivity monitoring from MainScene
m.connectivityTask = CreateObject("roSGNode", "ConnectivityTask")
m.connectivityTask.observeFieldScoped("hasInternet", "OnConnectivityChanged")
m.connectivityTask.control = "RUN"

sub OnConnectivityChanged()
    if m.connectivityTask.hasInternet
        HideOfflineDialog()
    else
        ShowOfflineDialog()
    end if
end sub

' Force an immediate check after recovering from sleep mode
m.connectivityTask.checkNow = true

' Stop when the channel is closing
m.connectivityTask.control = "stop"
hasInternet reflects reachability to the configured server, not just general internet access. A device may have an active Wi-Fi connection but still return false if the GlobalTV backend is unreachable.

Build docs developers (and LLMs) love