HandshakeTask runs RunHandshake on a worker thread. It finds a reachable server, POSTs device identity information to PATH_HANDSHAKE, and stores the result in global state. The handshake runs once at startup before authentication.
XML component definition
HandshakeTask.xml
Input fields
Optional. When non-empty, bypasses the automatic server discovery and uses this URL as the only candidate. Useful for manual server configuration in the settings screen. The value is normalised by
GTV_ServerNormalizeBaseUrl() before use.Output fields
Populated when
done becomes true. Contains the fields listed in the Result object section.Set to
true when the task finishes, whether successful or not.Result object
| Key | Type | Description |
|---|---|---|
success | Boolean | true when the server accepted the handshake |
server | String | Base URL of the server that responded |
realtimeMode | String | Delivery mode returned by the server; defaults to "polling" |
errorCode | Integer | HTTP code of the last failed attempt, or -1 for a network error |
errorMsg | String | Localised error string on failure |
Global state written
On success, the task writes the followingm.global fields:
| Field | Source |
|---|---|
m.global.deviceId | roDeviceInfo.GetChannelClientId() |
m.global.deviceModel | roDeviceInfo.GetModelDisplayName() |
m.global.osVersion | GTV_NormalizeOsVersion(di) — handles string, array, and assoc-array formats |
m.global.activeServer | The resolved server URL |
m.global.rida | roDeviceInfo.GetRIDA() |
m.global.lat | roDeviceInfo.IsRIDADisabled() |
m.global.deviceTimezone | roDateTime.GetTimeZoneOffset() |
m.global.deviceIp | deviceIp field from the server response (if present) |
m.global.realtimeMode | realtimeMode field from the server response |
Function flow
Resolve server
Calls
GTV_FindActiveServer(forcedServer). If forcedServerUrl is set, only that URL is tried. Otherwise, the full server probe list is used. A failure here ends the task immediately.Collect device info
Reads
GetChannelClientId(), GetModelDisplayName(), GTV_NormalizeOsVersion(), and GTV_GetAppVersion(). Also reads GetRIDA() and IsRIDADisabled() for ad-targeting context.POST handshake
Builds a JSON payload with
platform, device_id, device_model, os_version, and app_version, then calls GTV_HttpPost(url, jsonStr, TIMEOUT_HTTP). The URL is server + PATH_HANDSHAKE.Retry with failover
Retries up to
RETRY_MAX (3) times. On network error, advances to the next server in GTV_ServerBuildRequestSequence(). Stops immediately on HTTP 401 or 403 (auth required).Parse response
Cleans and parses the JSON body with
GTV_CleanJson() and ParseJson(). Reads realtimeMode and deviceIp from the response.AppConstants values used
| Constant | Value | Used for |
|---|---|---|
TIMEOUT_HTTP | 12000 ms | HTTP timeout for the handshake POST |
RETRY_MAX | 3 | Maximum handshake attempts across servers |
PATH_HANDSHAKE | "/api/v1/app/devices/handshake" | Endpoint path for the handshake POST |
PLATFORM | "roku" | Value sent in the platform field of the payload |