David Blume's GitList
Repositories
dxb_channel.git
Code
Commits
Branches
Tags
Search
Tree:
ee23104
Branches
Tags
main
dxb_channel.git
components
testtask.brs
Add some invariant info to the Launch Params panel.
David Blume
commited
ee23104
at 2020-03-28 13:58:02
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() for each key in aaConnectionInfo 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 m.top.updateText = "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