2017-12-27 1565 views
0

我正在尝试使sample auth linking Roku channel正常工作。我在我的Roku手柄上安装了频道,设置了用于生成和验证令牌的端点,但无法让断开端点工作。 Roku Developer Documentation on Authentication and Linking也没用,因为该页面上的响应与我实际从我的应用程序返回的内容不匹配。尝试在Roku通道中断开连接会引发错误

我的代码断开看起来像这样:

sub parseDis(job as object) 
    result = job.context.context.response 
    json = parseJSON(result.content) 
    if json.success = "no" 
    m.top.disconnect = false 
    else 
    m.top.disconnect = true 
    end if 
end sub 
从我的应用程序

所以,我回一个JSON响应,看起来像这样:

{ 
    "success": "yes" 
} 

但在Telnet调试控制台会话我得到这个输出:

Suspending threads... 
Thread selected: 2* ...:/components/RegistryTask.xml(55)  
Current Function: 
052: sec.Write(key, val) 
     Function RegWrite(key, val, section=invalid) 
053:   if section = invalid then section = "Default" 
054:   sec = CreateObject("roRegistrySection", section) 
055:*   sec.Write(key, val) 
056:   sec.Flush() 'commit it 
057:  End Function 
Type Mismatch. (runtime error &h18) in pkg:/components/RegistryTask.xml(55) 
055:   sec.Write(key, val) 
Backtrace: 
#1 Function regwrite(key As Dynamic, val As Dynamic) As Dynamic 
    file/line: pkg:/components/RegistryTask.xml(55) 
#0 Function go() As Void 
    file/line: pkg:/components/RegistryTask.xml(35) 
Local Variables: 
key    roString refcnt=3 val:"UNIQUE_ID_HERE3500X" 
val    Invalid 
section   String (VT_STR_CONST) val:"Default" 
global   Interface:ifGlobal 
m    roAssociativeArray refcnt=3 count:3 
sec    bsc:roRegistrySection refcnt=1 
Threads: 
ID Location        Source Code 
0 pkg:/source/main.brs(15)    msg = wait(0, m.port) 
1 pkg:/components/SimpleScene.brs(78)  oauth_token: invalid 
2* ...:/components/RegistryTask.xml(55) sec.Write(key, val) 
3[u] ?? 
    *selected [u]unattached(not debuggable) 

任何一个能够帮助我解释发生了什么事情并出错?

回答

1

的直接原因错误是这样的:

key    roString refcnt=3 val:"UNIQUE_ID_HERE3500X" 
val    Invalid 

Write()函数有两个字符串,键和值 - 在这种情况下该值为invalid,没有好。

我有一个快速浏览一下示例应用程序和更深层次的原因的背后是onDisconnect()事件处理程序:

m.regTask.write = { 
    deviceID: m.rokuDeviceID, 
    oauth_token: invalid 
} 

必须被固定的这种或那种方式。我没有看到更多的细节 - 例如如果空串会做逻辑或更好地使用roRegistrySection.delete()

相关问题