2017-12-27 1572 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()

相關問題