User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Fri Mar 13, 2009 12:47 am

I'm lazy and don't feel like testing this, search yielded no results, so I'll ask instead…
No big rush on these. Don't feel you have to answer them all today or in one reply.


#1 If I add multiple Channel Hooks to the same Channel, are they called in the order that they appear in the list, top to bottom?
I think the answer is yes. That's why you included the "Move Item Up" and "Move Item Down" buttons.


#2 Are multiple Channel Hooks attached to the same Channel, called synchronously or asynchronously?
I think the answer is synchronous.


#3 If the answer to #2 is synchronous, if a Channel Hook encounters an error (and maybe, writes anything to the error output (stderr) or returns a non-zero exit code) do subsequently listed Channel Hooks still get called or does subsequently listed Channel Hook processing continue? Does stderr output constitute an error? Does a non-zero exit code constitute an error?
I'm guessing subsequently listed Channel Hooks will still get called; not sure about what constitutes an error.


#4 Is there a timeout on Channel Hooks and if so what's the timeout interval?
I'm guessing there is a timeout, but wouldn't be surprised if there isn't a timeout.


#5 If a Channel Hook never returns an exit code and never writes anything to stderr and a timeout occurs, do subsequently listed Channel Hooks still get called or does subsequently listed Channel Hook processing continue?
I'm guessing subsequently listed Channel Hooks will still get called.


#6 When are the Channel Hook parameters, both global and instance, read by Awasu? When Awasu first runs? When the Channel is updated? Right before each Channel Hooks is called? At different times depending upon the registered event(s)? At different times depending upon whether it's a global parameter or an instance parameter?
I'm guessing it's "When the Channel is updated" based upon the presence of the "BeginChannelUpdate" event.


#7 "Commands" can be defined for Channel Hooks; can you give me some details on how these commands are invoked? I'm not talking about invoked as in "the user clicks a menu item", more like how does Awasu know how to dig into a Python script and call a function? I can see that it works with Python and some of the DLL-based Channel Hooks, but what about other programming languages? If someone wanted to create a Channel Hook in Java or a .NET-based language, can they define Commands?
I have no clue on this one. I'm not expecting you to give me a "how to" for every language so if part of your answer is "I've only tested Commands with C++ and Python" that is a perfectly acceptable answer.


#8 Is there a limit on the number of global parameters that that can be defined for a Channel Hook?
I don't have a guess on this question.


#9 Is there a limit on the number of instance parameters that that can be defined for a Channel Hook?
I don't have a guess on this question.


Thank in advance for your help! :bow:

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Fri Mar 13, 2009 9:10 am

kevotheclone wrote:#1 If I add multiple Channel Hooks to the same Channel, are they called in the order that they appear in the list, top to bottom?
I think the answer is yes. That's why you included the "Move Item Up" and "Move Item Down" buttons.

Correct.

kevotheclone wrote:#2 Are multiple Channel Hooks attached to the same Channel, called synchronously or asynchronously?
I think the answer is synchronous.

Also correct.

kevotheclone wrote:#3 If the answer to #2 is synchronous, if a Channel Hook encounters an error (and maybe, writes anything to the error output (stderr) or returns a non-zero exit code) do subsequently listed Channel Hooks still get called or does subsequently listed Channel Hook processing continue?

Processing continues. Channel hooks are independent of each other and I'd be quite annoyed if my hook wasn't being called because somebody else had an error.

kevotheclone wrote: Does stderr output constitute an error? Does a non-zero exit code constitute an error?

Yes and yes.

kevotheclone wrote:#4 Is there a timeout on Channel Hooks and if so what's the timeout interval?
I'm guessing there is a timeout, but wouldn't be surprised if there isn't a timeout.

No, there has to be one. Channel hooks get invoked as part of updating a channel so if one got stuck, the channel would never finish updating.

The global setting is in the Advanced tab of the Program Options (Script timeout). This is the default timeout any time Awasu runs an external program. For channel hooks, you can also define a global or per-instance <tt>ScriptTimeout</tt> parameters.

kevotheclone wrote:#5 If a Channel Hook never returns an exit code and never writes anything to stderr and a timeout occurs, do subsequently listed Channel Hooks still get called or does subsequently listed Channel Hook processing continue?
I'm guessing subsequently listed Channel Hooks will still get called.

As explained above, external programs *must* finish and Awasu will terminate them if they timeout.

kevotheclone wrote:#6 When are the Channel Hook parameters, both global and instance, read by Awasu? When Awasu first runs? When the Channel is updated? Right before each Channel Hooks is called? At different times depending upon the registered event(s)? At different times depending upon whether it's a global parameter or an instance parameter?
I'm guessing it's "When the Channel is updated" based upon the presence of the "BeginChannelUpdate" event.

Hmmm, your first wrong guess :-) For all config files, Awasu reads them at startup and then keeps them in memory.

kevotheclone wrote:#7 "Commands" can be defined for Channel Hooks; can you give me some details on how these commands are invoked? I'm not talking about invoked as in "the user clicks a menu item", more like how does Awasu know how to dig into a Python script and call a function?

It doesn't. Awasu has no knowledge of what language an external program is written in so it couldn't possibly do anything like this. All it knows is how to run the program. It passes through which command the user invoked via the INI file (the same way it passes through what event occurred when running a hook to process an event).

kevotheclone wrote:I can see that it works with Python and some of the DLL-based Channel Hooks, but what about other programming languages? If someone wanted to create a Channel Hook in Java or a .NET-based language, can they define Commands?

It doesn't matter what language you use, it's completely generic. As the help says, "read an INI file and write to the console" is all you need to be able to do.

kevotheclone wrote:#8 Is there a limit on the number of global parameters that that can be defined for a Channel Hook?
I don't have a guess on this question.

Absolutely. When Awasu starts up, it reads the parameters from the channel's config file in a loop using an int to index, so you can have at most 4,294,967,295 parameters. Of course, you're much more likely to run out of memory storing the details of all those parameters before you hit that limit :roll: And your users will hate you when they see them all in the UI... :D

kevotheclone wrote:#9 Is there a limit on the number of instance parameters that that can be defined for a Channel Hook?
I don't have a guess on this question.

See 8 :-)

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Sat Mar 14, 2009 1:01 am

Wow! Thanks for the super speedy and thorough response! :clap:

On item #6, one of the things that influenced my guess was that I’ve seen that you can update an existing Channel Hook’s parameters in the Channel Hooks Properties dialog box, without having to restart Awasu. So I think the really complete answer would be something like: "For all config files, Awasu reads them at startup and then keeps them in memory, where they can be further modified via the Channel Hooks Properties dialog box."

Also, one of the reasons I was asking about #6 was that to see if there was a way within Awasu to pass parameters or error codes between Channel Hooks. One thing I though of is: based upon Channel Hook #1's execution it could modify the .hook file of Channel Hook #2; if Awasu read the hook file "Right before each Channel Hooks is called" then this could be a mechanism to pass values or success/error states between Channel Hooks. Looks like it's not an option, but that's ok; there's other ways to pass values: read/write to files, read/write to the registry, environment variables, etc.

On item #7, it's been quite a while since I looked at the internals of the LogChannelActivity.py file and I guess I missed all the code related to calling the "processEvent" function vs. the "processCommand" function. After re-reading it I totally get it. Can we forget question #7 was ever asked and never speak of it again. :oops:

Ok, I think I'm pretty clear on Channel Hooks. ::-):


Return to “Awasu - Extensions”

Who is online

Users browsing this forum: No registered users and 1 guest