【问题标题】:Attempting to disconnect in Roku channel throws error尝试在 Roku 频道中断开连接会引发错误
【发布时间】:2017-12-27 18:19:17
【问题描述】:

我正在尝试让sample auth linking Roku channel 工作。我已经在我的 Roku 棒上安装了通道,设置了用于生成和验证令牌的端点,但无法使断开连接端点工作。 Roku Developer Documentation on Authentication and Linking 也无用,因为该页面上的响应与我必须从我的应用程序实际返回的响应不匹配。

我的断开连接代码如下所示:

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)

任何人都可以帮助我破译发生了什么和出了什么问题?

【问题讨论】:

    标签: roku brightscript


    【解决方案1】:

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

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

    Write() 函数接受 2 个字符串,键和值 - 在这种情况下,值是 invalid,不好。

    我快速浏览了示例应用程序,背后的更深层原因是 onDisconnect() 事件处理程序:

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

    这必须以一种或另一种方式解决。我没有看更多细节 - 例如如果空字符串对逻辑有用或更好地使用roRegistrySection.delete()

    【讨论】:

      猜你喜欢
      • 2019-04-25
      • 2018-11-23
      • 1970-01-01
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 2019-04-09
      • 2018-01-07
      • 2021-09-18
      相关资源
      最近更新 更多