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

SetSourceIdentity() - where and when?

ifSourceIdentity supposedly applies to roChannelStore, roChannelStoreEvent and roUrlEvent. It lists a method SetSourceIdentity(int) but i cannot make that work - instead i get error:
BrightScript Debugger> ? st.setSourceIdentity(8)
Member function not found in BrightScript Component or interface. (runtime error &hf4) in $LIVECOMPILE(477)

Who allows it and what's the purpose of using it?
0 Kudos
4 REPLIES 4
RokuKC
Roku Employee
Roku Employee

Re: SetSourceIdentity() - where and when?

"EnTerr" wrote:
ifSourceIdentity supposedly applies to roChannelStore, roChannelStoreEvent and roUrlEvent. It lists a method SetSourceIdentity(int) but i cannot make that work - instead i get error:
BrightScript Debugger> ? st.setSourceIdentity(8)
Member function not found in BrightScript Component or interface. (runtime error &hf4) in $LIVECOMPILE(477)

Who allows it and what's the purpose of using it?


This is both a interface design lacking and a bug.
The design lacking is that there are cases where a component implements a named interface, but not all of the functions defined by that interface.
In some cases this is because an interface defines both getter and setter methods, but a particular component that references that interface may only implement getter methods.

The purpose would be that you can match up events with the object that generated them.

I.e. you should be able to match roChannelStoreEvent objects' GetSourceIdentity() value with the generating roChannelStore object's GetSourceIdentity() value.
The roChannelStore object automatically assigns itself a source identify value. (Although the current implementation has some issues that may make this unreliable).

Similarly you should be able to match roUrlEvent objects' GetSourceIdentity() value with the generating roUrlTransfer object's GetIdentity() value.
The roUrlTransfer object automatically assigns itself an identity value.

It appears to me that SetSourceIdentity() does not have any functional application exposure currently.
0 Kudos
EnTerr
Roku Guru

Re: SetSourceIdentity() - where and when?

Detailed explanation much appreciated, RokuKC!

Speaking of purpose and interfaces - does findMemberFunction() have a use in programs - that is, other than sanity checks in console (i.e. that can check if particular function actually is present - or is it just me being a "cuckoo" trying to use it)

My ponder continues to, do i have a way to peruse further the returned interface.
0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: SetSourceIdentity() - where and when?

"EnTerr" wrote:
Detailed explanation much appreciated, RokuKC!

Speaking of purpose and interfaces - does findMemberFunction() have a use in programs - that is, other than sanity checks in console (i.e. that can check if particular function actually is present - or is it just me being a "cuckoo" trying to use it)

My ponder continues to, do i have a way to peruse further the returned interface.


In some rare cases findMemberFunction may be useful for backward compatibility. If you have an app that uses a component API that was added in a particular firmware version, but your app also needs to run on some older firmware version, it could check for the API being supported before trying to use it.

There isn't any way to enumerate available components, interfaces or functions programmatically. (Not counting brute force / British Museum approach 🙂 ).
0 Kudos
EnTerr
Roku Guru

Re: SetSourceIdentity() - where and when?

"RokuKC" wrote:
In some rare cases findMemberFunction may be useful for backward compatibility. ...

Hm, on second thought - isn't findMemberFunction() also the best (as in "shortest", "fastest" and "reliable") way to check for most data types? Considering that
BrightScript Debugger> ? type(1), type(box(1)), type([1][0])
Integer roInt roInteger

BrightScript Debugger> ? findMemberFunction(1, "getInt"), findMemberFunction(box(1), "getInt"), findMemberFunction([1][0], "getInt")
<Interface: ifInt> <Interface: ifInt> <Interface: ifInt>

I mean if i want to check if a value is integer-y, instead of checking the string returned by type() against 3 different strings, i better use if findMemberFunction(1, "getInt") <> invalid then ...
0 Kudos