Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Random Exiting Of App

So this is day two trying to figure out this seemingly weird issue. I'm developing a channel that requires access. However, after collecting the access code from the user, I try to query a simple PHP page that I created for testing, but for some reason the app exits immediately at the GetToString() command. Granted, I'm a newbie, but this just really seems weird. There's no error or anything that's given. It just goes back to the channel selection screen.

Anyone have any idea what's causing this?

Thanks.


console_log("Submitting access code for verification")

console_log("Access code is a "+type(access_code))

request = CreateObject("roUrlTransfer")

access_url = m.access_code_verification_url+"?access_code="+access_code

console_log(access_url)

request.SetUrl(access_url)

console_log("Access URL is a "+type(access_url))

html = request.GetToString()

console_log(html)

xml = CreateObject("roXMLElement")
xml.Parse(html)

console_log("XML Parsed")



-------Console Log-------

10. Submitting access code for verification
11. Access code is a String
12. http://www.MyDomain.com/channel_verification_test.php?access_code=1111
13. Access URL is a String

שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos
3 REPLIES 3
RokuChris
Roku Employee
Roku Employee

Re: Random Exiting Of App

Shot in the dark... Are you closing a screen just before starting this process? And if so is it the only screen open in the channel at the time? A channel will exit without error any time you close all of its screens.
0 Kudos

Re: Random Exiting Of App

No, I'm not closing any screens. Or at least not explicitly. I pasted the entire file below for a better reference.

The process attempts to locate a code in the registry. If a code is not found then the roKeyboardScreen is displayed to collect the access code. After the user enters the code the script then takes that code and attempts to query the url for verification.

After your post, that got me to thinking. I don't have a background screen open. So maybe after the roKeyboardScreen returns the entered characters, is that screen then being closed?


' *****************************************************************************
' **
' ** Verify the user's access to the channel
' **
' *****************************************************************************
Function verify_user()
console_log("Verifying User")

' Check to see if there is something in the registry for the account
user_account = registry_read("user_account")

console_log("Read from the registry")

' If nothing is found, then request account information
' "Roku access code"?
if user_account = invalid then
console_log("Nothing was found in the registry for the user")

user_account = get_access_code()
endif

console_log("Verifying code")

' If something IS found in the registry, then query the server to check for
' account validation
verification = verify_access_code(user_account)

' If the account is not valid, delete the registry entry and request
' account information
if verification = false then
registry_delete("user_account")
verify_user()
else
' If the account IS valid, then go to the grid screen
m.access_code = verification
registry_write("user_account", verification)
return true
endif
End Function



' *****************************************************************************
' **
' ** Display the keyboard screen to collect the user's access code
' **
' *****************************************************************************
Function get_access_code()
console_log("Asking user for access code")

screen = CreateObject("roKeyboardScreen")
port = CreateObject("roMessagePort")

screen.SetMessagePort(port)
screen.SetTitle("Access Code")
screen.SetDisplayText("Please enter your access code for this Roku channel")
screen.SetMaxLength(8)
screen.AddButton(1, "Finished")
screen.AddButton(2, "Back")
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())

if type(msg) = "roKeyboardScreenEvent"
if msg.isScreenClosed()
'exit while
End
else if msg.isButtonPressed() then
if msg.GetIndex() = 1
searchText = screen.GetText()

console_log("Returning entered code ("+searchText+")")

return searchText
exit while
else if msg.GetIndex() = 2
console_log("Exiting app")
End
endif
endif
endif
end while
End Function



' *****************************************************************************
' **
' ** Query the site for verification of the access code
' **
' *****************************************************************************
Function verify_access_code(access_code=invalid)
' If we don't have the access code to verify then we have nothting to do
' Return false and don't do anything
if access_code = invalid OR access_code = ""
return false
endif

console_log("Submitting access code for verification")

console_log("Access code is a "+type(access_code))

' Hit up the verification URL with the access_code for verification
request = CreateObject("roUrlTransfer")

access_url = m.access_code_verification_url+"?access_code="+access_code

console_log(access_url)

request.SetUrl(access_url)

console_log("Access URL is a "+type(access_url))

html = request.GetToString()

console_log(html)

xml = CreateObject("roXMLElement")
xml.Parse(html)

console_log("XML Parsed")

if xml.verified then
console_log("Access code verified")
return access_code
else
console_log("Access code was not verified")
return false
endif
End Function
שלום חבר

Dean at the School of Truth: a part of Autodidact University.

"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum
0 Kudos
TheEndless
Channel Surfer

Re: Random Exiting Of App

"DukeOfMarshall" wrote:
So maybe after the roKeyboardScreen returns the entered characters, is that screen then being closed?

Yes. Your keyboard screen is scoped to the get_access_code function, so it's going to get disposed as soon as that function returns. You also call "End" in your "isScreenClosed()" event for that screen which is a bad idea. If you want to exit the channel if the keyboard screen is closed, then it'd probably be better to do so if get_access_code doesn't return a value, instead of doing it explicitly inside that function.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.