Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Sometimes in a Glish system two clients need to communicate as fast as possible. If the system's Glish script only forwards events from one client to the other without modifying the events' values then you instead use a direct connection between the two. Glish supports this style of communication using the link statement. When executed, a link statement directs a client to send a particular event it generates directly to another client (perhaps renaming it). For example,
link t->transformed_data to d->new_datacauses the client associated with t to send its transformed_data events directly to d's client, that sees them as new_data events. (Other events generated by t's client still go to the Glish interpreter.) The destination of a link can use the ``*" event to mean ``use the same name":
link t->transformed_data to d->*sends the transformed_data events along without renaming them.
You can suspend point-to-point links with the unlink statement:
unlink t->transformed_data to d->new_dataThis suspends the link formed in the first example above. Now t's agent sends its transformed_data events to the Glish interpreter and executes the corresponding whenever bodies. Executing another link statement restores the point-to-point link.
Presently, executing a link statement twice causes two links to be established. Thus
link a->foo to b->bar link a->foo to b->barcauses a to send each foo event to b twice (i.e., b sees two bar events). It seems unlikely that this behavior is desirable, since there may be times when you want to establish a link and are not sure if it has already been established. So you should not rely on this behavior as it may well change in the future.