next up previous contents index
Next: Creating Clients Up: Events Previous: await Statement

Point-to-Point Communication

 

  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 we can 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_data
will cause the client associated with t to send its transformed_data events directly to d's client, which will see 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->*
will send 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_data
suspends the link formed in the first example above. t's agent will now instead send its transformed_data events to the Glish interpreter, which will execute 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->bar
causes a to send each foo event to b twice (i.e., b will see two bar events). It seems unlikely that this behavior is desirable, since there may be times when you wish to establish a link and are not sure if it has already been established. So users should not rely on this behavior as it may well change in the future.



Thu Nov 13 16:44:05 EST 1997