InfotronDoc

Infotron API

Each infotron instance has access to these member variables and methods

Member Variables

id string

the string identifier specified using the “id” attribute on the “div” element used to declare the infotron.

name string

the string identifier speficified using the “name” attribute on the “div” element used to declare the infotron.

dom_node object reference

Once an infotron is constructed, it is free to manipulate the “div” DOM node used for its declaration. The reference to this DOM node is found in the "dom_node" member variable.

bp_uuid string

a string UUID of the blueprint which the infotron is an instance of.

Domain Proxy Specific Member Variables

is_ready_for_message_pumping boolean

Must be initially set to false by the Domain Proxy infotron. It should change it to true sometime after its overridden _onChildConstruct method has been invoked. If it is not changed to true, it will not receive any messages.

The “Domain Proxy” infotron uses this member variable to communicate with JS-Star on whether the HTML domain is ready to get messages delivered.

Methods

blockAllTerminalsExcept(array of terminal names)

Prevents messages arriving at any input terminal, except the ones specified in the first argument, from invoking its handler.

Messages arriving at the blocked terminals will become queued up until their respective queue limits are reached. The following sample code prevents the handler associated with all input terminals except “trigger” from being invoked.

example:

this.blockAllTerminalsExcept([“trigger”]);

blockAllTerminals()

Prevents messages arriving at all terminals from invoking their associated handlers.

unblockAllTerminals()

Allows all previously queued up messages to invoke their handlers and continue the natural flow of messages delivery. The method does not take any arguments.

onMsg(input terminal name, function reference)

Used to modify the handler function associated with an input terminal. The following sample code registers the function referenced by the variable func to become the handler of all messages delivered to the input terminal “trigger”:

this.onMsg(“trigger”, func);

postMessage(output terminal name, message)

Messages can be posted to an output terminal using the postMessage method. The following example shows how an infotron can be programmed to post a message (an integer value of 1 in this case) to the “timeout_event” output terminal:

this.postMessage(“timeout_event”,1);

popMessage(input terminal name)

Used to pop a message from an input terminal. The following sample code pops and returns the first message queued at the input terminal “trigger”:

this.popMessage(“trigger”);

error(log string)

debug(log string)

warning(log string)

caution(log string)

info(log string)

The abve five methods are available for logging. However, JS-Star does not provide the implementation for these facilities. These interfaces exist primarily as a hook to an external logging API. They are no-op functions in the absence of an external logging API. The JDA distribution comes with a simple implementation of these logging facilities.

Special Terminal

%startup

This input terminal is a special terminal that when associated with a handler method, gets injected a message by Star to indicate that the infotron may start using the postMessage method to communicate to other infotrons in the same domain. Whether infotrons outside the domain is reachable is undefined.

Event Handler Methods

The following is a list of event-handling methods that you can override to carry out special routines of your own.

_onStartUp()

called once right before the very first message arrives at the infotron.

_onMsgDelivery(input terminal name, message)

called by Star to deliver a message queued up at an input terminal.

If this method is overridden, the original terminal handler associated with the input terminal in the blueprint will not be called.

_onDestruct()

called once by Star inside the __star.shutDown method call. If an infotron needs to carry out additional clean up, this would be the method to override.

Domain Proxy Specific Event Handlers

The following two methods are intended for use only by the “Domain Proxy” infotron.

_onConstructInternal()

called by Star on a “Domain Proxy” infotron to request that the domain be constructed because a message needs to be delivered. This handler will only be called if a message arrives before it has finished constructing its domain. This method is typically overridden to lazily construct a domain.

_onChildConstruct( _ id , input terminals, output terminals_)

called by Star on a “Domain Proxy” infotron when the proxied domain finishes constructing and calls the allowMessagingToChild method. The first argument is the id of the element (i.e., iframe/window) that wraps the domain. The second and third arguments are input and output terminals that belong to the constructed domain.



Copyright © 2006–2008 by Assembla, LLC / Phone 1.781.328.2241 / E-mail: info@assembla.com