David Blume's GitList
Repositories
dxb_channel.git
Code
Commits
Branches
Tags
Search
Tree:
0a6f57c
Branches
Tags
main
dxb_channel.git
source
main.brs
Fix static analysis problems. Add some logging.
David Blume
commited
0a6f57c
at 2020-05-06 22:25:57
main.brs
Blame
History
Raw
sub Main(launchParams) ' Just to test various ECP params print "Launch parameters:" for each key in launchParams print " " key "=" launchParams[key] end for ' Indicate this is a Roku SceneGraph application' screen = CreateObject("roSGScreen") port = CreateObject("roMessagePort") screen.SetMessagePort(port) pucid = GetPUCID() if pucid <> invalid pucidHash = Sign(pucid) print "PUCID: " + pucid + ", hash: " + pucidHash else pucidHash = "" print "Error: PUCID is not valid" end if ' Create a scene and load /components/dxb.xml' m.scene = screen.CreateScene("dxb") m.scene.setField("pucidHash", pucidHash) screen.show() m.scene.signalBeacon("AppLaunchComplete") while(true) msg = wait(0, port) msgType = type(msg) print "dxb Main loop msgType = " msgType if msgType = "roSGScreenEvent" if msg.isScreenClosed() then return end if end while end sub function Sign(key) as String evp = CreateObject("roEVPDigest") ba = CreateObject("roByteArray") ba.FromAsciiString(key) evp.Setup("md5") evp.Update(ba) md5 = evp.Final() base64 = CreateObject("roByteArray") base64.FromHexString(md5) hashedKey = base64.ToBase64String() return hashedKey end function function GetPUCID() as String key = invalid appInfo = CreateObject("roAppInfo") if appInfo.IsDev() = true key = "my-secret" else cs = CreateObject("roChannelStore") res = cs.GetChannelCred() if res <> invalid if res.json <> invalid and res.json <> "" json = ParseJson(res.json) key = json.roku_pucid end if end if end if return key end function