Skip to main content
All tasks extend the SceneGraph 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.
File: components/tasks/AuthTask.*
Function: RunAuth

Purpose

Authenticates a username/password pair against the backend. Resolves the active server first (LAN probe → WAN fallback, up to SERVER_LAN_FORCE_RETRIES = 3 LAN attempts), then performs a GET to /auth/{user}/{pass} with TIMEOUT_AUTH = 15 000 ms.

XML interface

Input fields

Output fields

Result structure

Completion signal

Observe done. When done = true, read result. result.success = true means authentication passed; result.subscriberActive confirms the subscriber account is active.

Auth reason codes

File: components/tasks/PlaylistTask.*
Function: RunPlaylist

Purpose

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

Output fields

Result structure

Each entry in result.channels is a channel object:

Completion signal

Observe done. On success, result.channels and result.categories are populated and also written directly to m.global.channelList / m.global.categories.

Logging

The task logs extinf_sample lines (first 3 #EXTINF entries), a logo_summary, and up to 5 channel_sample lines at the GTV_Log level.
File: components/tasks/AdsPollingTask.*
Function: RunAdsPolling

Purpose

Long-running polling task. Performs the initial ads handshake (if ADS_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

Output fields

Completion signal

This is a long-running task; it does not use a done field. Stop it by setting control = "stop".

Poll endpoint

Requests are sent to ADS_API_BASE_URL + ADS_PATH_ACTIVE (default: https://ads.globaltv.lat/api/v1/app/ads/active) with query parameters:
or, if 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.
File: components/tasks/ConnectivityTask.*
Function: RunConnectivityTask

Purpose

Periodic network health checker. Pings the active server’s health endpoint every 10 seconds and updates m.global.hasInternet / m.global.isOnline. Suppresses log spam by only logging on state transitions.

XML interface

Fields

Completion signal

Long-running task. Stopped via control = "stop". Output is written continuously to hasInternet and m.global.

Check logic

File: components/tasks/HandshakeTask.*
Function: RunHandshake

Purpose

Performs the initial device handshake with the backend. Probes the server list to find a reachable endpoint, then POSTs device information to PATH_HANDSHAKE = /api/v1/app/devices/handshake. Sets m.global.activeServer, m.global.deviceId, m.global.realtimeMode, and device metadata.

XML interface

Input fields

Output fields

Result structure

Completion signal

Observe done. 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

File: components/tasks/MetricsTask.*
Function: RunMetrics

Purpose

Long-running event sink. Waits for trackEvent 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

Event object structure

For impression batch events, use eventType = "ad_impression_closed" and add:
Impression events with visible_ms < 1000 are silently dropped. Duplicate event_uuid values within a session are deduplicated.

Completion signal

Long-running task. Stopped via control = "stop". Auth failures (HTTP 401/403) permanently disable metric posting for the remainder of the session.
File: components/tasks/ServerProbeTask.*
Function: RunServerProbe

Purpose

One-shot task that probes a single server URL by calling GTV_PingServer(). Used by SettingsScreen to test connectivity to a specific server profile before applying it.

XML interface

Input fields

Output fields

Result structure

success = true means GTV_PingServer() received an HTTP response in the range 200–499 within TIMEOUT_HEALTH = 2 500 ms.

Completion signal

Observe done. Check result.success for the probe outcome.