<docbook><section><title>OATDOCmessaging</title><para> </para>
<title> Messaging</title> Messaging
<para>How to send &amp; receive inter-control messages</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Functions</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.MSG.send(sender, message, event)</bridgehead>
<para>Dispatches a message.</para>
<itemizedlist mark="bullet" spacing="compact"><listitem><emphasis>sender</emphasis> - to object sending this message.
</listitem>
<listitem><emphasis>message</emphasis> - a constant, defined in OAT.MSG.
 Developers are encouraged to add more message types.
 Examples include OAT_LOAD,TREE_EXPAND, and AJAX_FAILURE.
</listitem>
<listitem><emphasis>event</emphasis> - an object carrying data relevant to this message; no particular format is required.</listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.MSG.attach(sender, message, callback)</bridgehead>
<para>Subscribes to messages.</para>
<itemizedlist mark="bullet" spacing="compact"><listitem><emphasis>sender</emphasis> - the object whose messages we want to receive; value of &quot;*&quot; means ALL senders.
</listitem>
<listitem><emphasis>message</emphasis> - the message we want to receive; it is possible to use &quot;*&quot; or <ulink url="RegExpmatches">RegExpmatches</ulink> here.
</listitem>
<listitem><emphasis>callback</emphasis> - When a message arrives, callback is executed with arguments passed to appropriate OAT.MSG.send()function.</listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.MSG.detach(sender, message, callback)</bridgehead>
<para>Detaches previously set message receiving handler.
 All three fields must match.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Example</bridgehead>
<programlisting>/* assume that there exists OAT.MSG.CUSTOM_MESSAGE */

function myMessageHandler(source, message, event) {
        alert(&quot;Message arrived!&quot;(;
}

/* subscribe to receiving... */
OAT.MSG.attach(&quot;*&quot;,&quot;CUSTOM_.*&quot;,myMessageHandler);

/* dispatch message */
OAT.MSG.send(this, OAT.MSG.CUSTOM_MESSAGE, {}); // will invoke myMessageHandler 
</programlisting><para> <ulink url="CategoryDocumentation">CategoryDocumentation</ulink> <ulink url="CategoryOAT">CategoryOAT</ulink> <ulink url="CategoryOpenSource">CategoryOpenSource</ulink></para>
</section></docbook>