"AlexHolsgrove" wrote:
I am a new Roku developer and am just getting started with BrightScript.
I have the Device Registration example code running on my Roku HD3 and this is talking to a local server running PHP. The process works, but I have noticed that the while loop with the delay doesn't really get executed. I've logged all of the GET/POST calls to the server and it seems that the Roku is making hundreds of requests to the "getRegResult" endpoint - this is within the "checkRegistrationStatus" function.
Can anyone point me in the right direction to getting this example code working properly (eg using the retryInterval/retryDuration variables)
Thanks,
Alex
I just ran the example code "as is" (getting the registration code from rokudev.roku.com.) It seems to work just fine (sort of).
I'm not sure why there's a loop in checkRegistrationStatus. It's supposed to make a single request to the server and return a value indicating whether the user has registered yet. If you want to simulate the user not having registered, and the main loop polling (the one in doRegistration), then add this line of code in checkRegistrationStatus after token = e.GetBody()
token = "" ' Simulate failing to get registration code
If I were you, I'd re-write checkRegistrationStatus. The Roku code looks very strange. For instance, there's code to extract customerId and creationTime elements from the response, but it will never get executed if they come after the regToken element, neither will the print statement and return statement at the end of the function. And the code will end up in an infinite loop if the server returns a result containing no regToken element.
If your code is looping in checkRegistration it might be because there's something messed up with the response your PHP server is returning [most likely your server is returning a <result> but no <regToken> element]. Try putting some code in checkRegistrationStatus to print the server response. E.g. after rsp = http.Http.GetToString()
print "Registration Status Response: " + rsp
Run the Roku example code "as is" then run the code against your PHP server and compare the responses to see if your server is returning the same format response as the Roku server.