Skip to main content
File: source/utils/Logger.brs

Purpose

Three-level logging facade. GTV_Log is gated on the IS_DEV_BUILD compile-time constant; GTV_Warn and GTV_Error always print.

Functions

Output format examples

See Logging for full details on enabling dev logging and viewing output.
File: source/utils/HttpClient.brs

Purpose

HTTP request wrapper for all backend calls. Handles TLS certificates, platform headers, user-agent, async execution, and timeout cancellation. The function signature defaults to 15 000 ms; callers pass TIMEOUT_HTTP = 12 000 ms or TIMEOUT_AUTH = 15 000 ms explicitly.

Functions

Performs an async GET. Returns:

Performs an async POST with a JSON body. Same return shape as GTV_HttpGet.
Builds a URL-encoded query string from an AssocArray. Values are escaped with GTV_UrlEncode.
Escapes a string using roUrlTransfer.Escape().
Builds the User-Agent header string.Example: GlobalTV_Roku/1.0.7 (roku; Roku Express; 12.5.0)

Request headers set on every call

Timeout constants (from AppConstants)

File: source/utils/RegistryManager.brs

Purpose

Thin wrapper around roRegistrySection for persistent key-value storage. All reads/writes use the registry section "GlobalTV" (REG_SECTION constant). Flush is called automatically on every write.

Core functions

Credential functions

Server / cache functions

Channel index functions

Safe-area margin functions

Registry key names (from AppConstants)

File: source/utils/ServerManager.brs

Purpose

Server list management. Maintains a list of server profiles (LAN and WAN), builds probe sequences with LAN-first retry behavior, resolves the active server, and provides CRUD operations on profiles.

Key functions

Default server profiles

LAN retry behavior

SERVER_LAN_FORCE_RETRIES = 3 — the LAN server URL is inserted 3 times at the head of the probe list before WAN servers are tried. This prioritizes the local server without completely blocking on a single failure.
File: source/utils/M3UParser.brs

Purpose

M3U8 playlist parser. Extracts channel metadata from #EXTINF lines and builds sorted channel and category arrays. Enforces or relaxes channel number requirements via PARSER_STRICT_CHANNEL_NUMBER.

Main function

Parses an M3U8 string. Returns:

Strict mode (PARSER_STRICT_CHANNEL_NUMBER = true)

When enabled (the default), any #EXTINF entry that does not have a valid channel-number attribute greater than 0 is dropped and counted in droppedMissingNumber. Duplicate channel numbers are also dropped.When disabled, entries without a channel-number receive an auto-incremented fallback index and are counted in fallbackAssigned.

Attribute extraction

Supported #EXTINF attributes

URL normalization

Stream ID extraction

Sorting

Channels are sorted ascending by channel.number using an insertion sort (GTV_SortChannels).
File: source/utils/HealthCheck.brs

Purpose

Single-function HTTP health prober. Used by ServerManager, ConnectivityTask, and all tasks that need to determine whether a server is reachable before making a real request.

Function

Sends an async GET to baseUrl + PATH_HEALTH (/health) with a timeout of TIMEOUT_HEALTH = 2 500 ms.Returns true if the HTTP response code is in the range 200–499 (i.e., the server is up even if it returns a client error). Returns false on timeout, connection failure, or HTTP 5xx.

TLS

For https:// URLs, CERTS = "common:/certs/ca-bundle.crt" is applied automatically.

Usage pattern

File: source/utils/NetworkDetector.brs

Purpose

Device-level network state detection. Uses roDeviceInfo.GetConnectionType() to check whether the Roku device has any network interface active, without making an outbound HTTP request.

Functions

Difference from HealthCheck

GTV_IsOnline() is a cheap local check (no network I/O). GTV_PingServer() makes an outbound HTTP call. ConnectivityTask uses both: GTV_IsOnline() writes to m.global.isOnline and GTV_PingServer() writes to m.global.hasInternet.