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: 
EnTerr
Roku Guru

roMessagePort as ifEnum?

I just noticed that roMessagePort implements ifEnum and i wonder what the fruits of this are. Under ifEnum, here is what it can do:
Reset()
dynamic Next()
bool IsNext()
bool IsEmpty()

port.isEmpty() i can imagine useful to check if there are any events waiting, instead of wait(port, 1) - with the bonus that it won't yank the event from the queue.

port.isNext() on the other hand seems funky, because it is hopeless optimist and always returns "true", no matter if there is event or not. Funky because in this way isNext() != not isEmpty(). I imagine this was made so that one can do FOR EACH msg IN port - and the loop does not exit when there are no pending messages.

port.next() seems to do exactly what port.waitMessage(0) does.

What does port.reset() do though, i wonder. The semantic is not apparent to me. Does it flush out all queued events? FWIW, i don't even know if message port does queue more than 1 event or does it keep only the last one? (PS. did small experiment and: yes, events get queued. no, reset() does not flush the queue)

Can someone shed light on my musings pls?
0 Kudos
2 REPLIES 2
EnTerr
Roku Guru

Re: roMessagePort as ifEnum?

bump!
Roku*, can you clarify?
0 Kudos
belltown
Roku Guru

Re: roMessagePort as ifEnum?

I tried using the 'for each msg in port' construct a while ago, only to find that it crashed my Roku. See http://forums.roku.com/viewtopic.php?f=34&t=44956

I don't know if they've fixed that bug yet, but in the end I just decided to stick with:

while true
msg = wait (0, port)
0 Kudos