David Blume's GitList
Repositories
dxb_channel.git
Code
Commits
Branches
Tags
Search
Tree:
4677389
Branches
Tags
main
dxb_channel.git
components
testtask.brs
Sort connection info
dblume
commited
4677389
at 2023-01-19 12:50:43
testtask.brs
Blame
History
Raw
sub init() m.top.functionName = "executeTest" m.top.ObserveField("pucidHash", "onUpdatePucidHash") end sub function GetRequest() as object r = CreateObject("roUrlTransfer") r.InitClientCertificates() r.SetCertificatesFile("pkg:/certificates/rokuca.pem") ' r.SetCertificatesFile("common:/certs/ca-bundle.crt") r.SetUrl("https://api.roku.com/registrysvc/api/" + CreateObject("roAppInfo").GetDevID()) r.AddHeader("accept", "application/json") r.AddHeader("content-type", "application/*") r.AddHeader("x-roku-registry-aes-key-version", "v1") r.AddHeader("x-roku-reserved-regsvc-token", "") ' Note if called from init(), then m.top.pucidHash won't have been set yet. r.AddHeader("x-roku-registry-aes-encryption-key", m.top.pucidHash) print "GetRequest() x-roku-registry-aes-encryption-key:" + m.top.pucidHash print " URL:" + r.GetUrl() return r end function function onUpdatePucidHash() as void ' Maybe do something with m.top.pucidHash end function function executeTest() as void ' This task gets run one at the start, and then ' again every time the OK button is pressed. deviceInfo = CreateObject("roDeviceInfo") aaConnectionInfo = deviceInfo.GetConnectionInfo() m.top.updateText = "roDeviceInfo.GetConnectionInfo" for each key in aaConnectionInfo.Keys() val = aaConnectionInfo[key] m.top.updateText = " " + key + " = " + val.ToStr() end for request = GetRequest() port = CreateObject("roMessagePort") request.SetMessagePort(port) requestBody = { "token": "auth" } res = request.AsyncPostFromString(FormatJson(requestBody)) if res = true msg = wait(0, port) if type(msg) = "roUrlEvent" if msg.GetInt() = 1 print "PSI Request roUrlEvent = " + msg.GetResponseCode().ToStr() end if ' else if msg = invalid ' request.AsyncCancel() end if else m.top.updateText = "AsyncPostFromString failed" end if end function