Task node. They are created with CreateObject("roSGNode", "<TaskName>"), have their input fields set, and are started with task.control = "RUN". Completion is signaled by setting a done field or — for long-running tasks — by writing output fields that the caller observes.
AuthTask
AuthTask
File:
Function:
components/tasks/AuthTask.*Function:
RunAuthPurpose
Authenticates a username/password pair against the backend. Resolves the active server first (LAN probe → WAN fallback, up toSERVER_LAN_FORCE_RETRIES = 3 LAN attempts), then performs a GET to /auth/{user}/{pass} with TIMEOUT_AUTH = 15 000 ms.XML interface
Input fields
| Field | Type | Description |
|---|---|---|
username | string | Plain-text username. |
password | string | Plain-text password. |
Output fields
| Field | Type | Description |
|---|---|---|
result | assocarray | Full auth result (see structure below). |
done | boolean | Set to true when the task finishes (success or failure). |
statusMessage | string | Human-readable progress text (e.g. “Conectando con servidor local…”). |
statusTick | integer | Incremented each time statusMessage changes; observe this to detect updates. |
Result structure
Completion signal
Observedone. When done = true, read result. result.success = true means authentication passed; result.subscriberActive confirms the subscriber account is active.Auth reason codes
| Constant | Value | Meaning |
|---|---|---|
AUTH_REASON_NONE | 0 | No error. |
AUTH_REASON_CREDENTIALS | 401 | Wrong username or password. |
AUTH_REASON_INACTIVE | 470 | Account is inactive. |
AUTH_REASON_PASSWORD_CHANGED | 471 | Password was changed; must re-login. |
AUTH_REASON_NETWORK_DOWN | 460 | Network or server unreachable. |
PlaylistTask
PlaylistTask
File:
Function:
Each entry in
components/tasks/PlaylistTask.*Function:
RunPlaylistPurpose
Downloads the authenticated M3U8 playlist from/auth/{user}/{pass}/playlist/m3u8/hls and parses it into channel and category arrays. Supports server failover: up to RETRY_MAX = 3 attempts across the server sequence.XML interface
Input fields
| Field | Type | Description |
|---|---|---|
username | string | Credential for the playlist URL. |
password | string | Credential for the playlist URL. |
Output fields
| Field | Type | Description |
|---|---|---|
result | assocarray | Full playlist result (see structure below). |
done | boolean | Set to true on completion. |
Result structure
result.channels is a channel object:Completion signal
Observedone. On success, result.channels and result.categories are populated and also written directly to m.global.channelList / m.global.categories.Logging
The task logsextinf_sample lines (first 3 #EXTINF entries), a logo_summary, and up to 5 channel_sample lines at the GTV_Log level.AdsPollingTask
AdsPollingTask
File:
Function:
or, if
components/tasks/AdsPollingTask.*Function:
RunAdsPollingPurpose
Long-running polling task. Performs the initial ads handshake (ifADS_HANDSHAKE_ENABLED = true), then polls the active snapshot endpoint every ADS_POLL_MS = 10 000 ms. Tracks impression versioning and signals session-level auth failures back to MainScene.XML interface
Input fields
| Field | Type | Description |
|---|---|---|
streamId | string | Current stream identifier (from channel streamId). |
streamPosition | string | Channel number string; fallback stream identifier. |
resetChannel | boolean | Set to true when the channel changes; resets sinceVersion and triggers an immediate poll. |
Output fields
| Field | Type | Description |
|---|---|---|
adData | assocarray | Normalized first ad from the latest snapshot. |
adsSnapshot | assocarray | Full snapshot object (version, ads array, stream info). |
adsCleared | boolean | Toggled false → true when the server signals no active ads. |
clearedStreamPosition | string | Stream position from the clear event. |
clearedStreamId | string | Stream ID from the clear event. |
userInactive | boolean | Toggled when the polling response indicates account inactivity. |
userInactiveReason | string | Localized reason string for the inactive state. |
sessionInvalid | boolean | Toggled when the response signals credential/password invalidation. |
sessionInvalidReason | string | Localized reason string. |
Completion signal
This is a long-running task; it does not use adone field. Stop it by setting control = "stop".Poll endpoint
Requests are sent toADS_API_BASE_URL + ADS_PATH_ACTIVE (default: https://ads.globaltv.lat/api/v1/app/ads/active) with query parameters:stream_id is unavailable:Handshake
Before the first poll,TryAdsHandshake() POSTs to ADS_PATH_HANDSHAKE with device and subscriber info. Failures are logged but do not block polling.ConnectivityTask
ConnectivityTask
File:
Function:
components/tasks/ConnectivityTask.*Function:
RunConnectivityTaskPurpose
Periodic network health checker. Pings the active server’s health endpoint every 10 seconds and updatesm.global.hasInternet / m.global.isOnline. Suppresses log spam by only logging on state transitions.XML interface
Fields
| Field | Direction | Type | Description |
|---|---|---|---|
hasInternet | output | boolean | true if the last health ping succeeded. Also written to m.global.hasInternet. |
checkNow | input | boolean | Set to true to trigger an immediate check outside the 10-second cycle. |
Completion signal
Long-running task. Stopped viacontrol = "stop". Output is written continuously to hasInternet and m.global.Check logic
HandshakeTask
HandshakeTask
File:
Function:
components/tasks/HandshakeTask.*Function:
RunHandshakePurpose
Performs the initial device handshake with the backend. Probes the server list to find a reachable endpoint, then POSTs device information toPATH_HANDSHAKE = /api/v1/app/devices/handshake. Sets m.global.activeServer, m.global.deviceId, m.global.realtimeMode, and device metadata.XML interface
Input fields
| Field | Type | Description |
|---|---|---|
forcedServerUrl | string | If set, bypasses auto-probe and connects only to this URL (used when the user manually selects a server in Settings). |
Output fields
| Field | Type | Description |
|---|---|---|
result | assocarray | Handshake result (see structure below). |
done | boolean | Set to true on completion. |
Result structure
Completion signal
Observedone. result.success = true means the handshake succeeded. HTTP 401/403 responses set result.errorCode to that HTTP code but are treated as “auth required” (not a hard failure) by MainScene.POST payload
MetricsTask
MetricsTask
File:
Function:
For impression batch events, use Impression events with
components/tasks/MetricsTask.*Function:
RunMetricsPurpose
Long-running event sink. Waits fortrackEvent field writes and POSTs each event to PATH_METRICS = /api/v1/app/metrics/track. Handles ad impression batch events separately via ADS_PATH_IMPRESSIONS.XML interface
Fields
| Field | Direction | Type | Description |
|---|---|---|---|
trackEvent | input | assocarray | Event object to post. Writing this field triggers PostEvent. |
lastResult | output | assocarray | Result of the most recent post: {ok, code, server}. |
Event object structure
eventType = "ad_impression_closed" and add:visible_ms < 1000 are silently dropped. Duplicate event_uuid values within a session are deduplicated.Completion signal
Long-running task. Stopped viacontrol = "stop". Auth failures (HTTP 401/403) permanently disable metric posting for the remainder of the session.ServerProbeTask
ServerProbeTask
File:
Function:
components/tasks/ServerProbeTask.*Function:
RunServerProbePurpose
One-shot task that probes a single server URL by callingGTV_PingServer(). Used by SettingsScreen to test connectivity to a specific server profile before applying it.XML interface
Input fields
| Field | Type | Description |
|---|---|---|
baseUrl | string | Server base URL to probe (e.g. https://admin.globaltv.lat). |
Output fields
| Field | Type | Description |
|---|---|---|
result | assocarray | Probe result (see structure below). |
done | boolean | Set to true when the probe completes. |
Result structure
success = true means GTV_PingServer() received an HTTP response in the range 200–499 within TIMEOUT_HEALTH = 2 500 ms.Completion signal
Observedone. Check result.success for the probe outcome.