Ad Hoc Communication

The protocols described above involve all behaviors in ways that they all understand, even if that understanding results in the behavior knowingly ignoring a protocol. Protocols satisfy the communication needs of the great majority of behaviors.

Various ad hoc communication involves smaller groups of behaviors. The communication is still open so that arbitrary behaviors can participate, but behaviors must know how to communicate in a language socially agreed upon by concerned behaviors outside of core definitions. Out-of-protocol communication can be made by leaving state in the document tree (in attributes and global variables), by manager behaviors, and by defining further protocols. As well, although all behaviors are presented with semantic events, they typically examine the message to determine whether the event is interesting to them, and since messages are simple strings, it's easy for groups of behaviors to coordinate on a new string, thus in effect spontaneously creating a new ad hoc communication on top of a well known transport.

Example: multipage.

Several document formats are paginated, including scanned paper, DVI, and PDF. Multipage documents share a set of behaviors that provide GUI controls for navigating pages and save and restore annotations between individual pages and a single file on disk.

Multipage behaviors define two attributes held in the document root, PAGECNT that holds the total number of pages in a document and PAGE that holds the current page number. Media adaptors interpret their specific medium and report the total number of pages, and during the build protocol they inquire for the value of PAGE and construct that page. Page numbers are given as positive integers; media adaptors may have to map a more complex numbering scheme, but the page navigation controls is guaranteed that the current page number plus one gives the next page.

Simply by referring to a particular behavior in their hub, multipage document formats can take advantage of per-page annotations that are saved to a common file. All document formats can be annotated with an open-ended set of annotation types, none of which is built in. Neither is the saving and restoring of annotations built in. An annotation manager behavior waits for a closedDocument semantic event, at which point it collects annotations writes them to disk, and restores them on a subsequent openedDocument. Multipage documents are more complicated since it was desirable to save annotations from all pages in a single file, the better to distribute the set as a unit. Multipage behaviors have socially defined an extension to openedDocument/closeDocument for pages; the multipage controls send openedDocumentPage and closeDocumentPage, and the save/restore annotation behavior responds to these. The pagewise annotation manager takes advantage of state in the Layer object, and stores annotations for pages other than the current page in data trees. This in turn is a state known by the wipe annotations behavior, so it can not only clear annotations for the current page as it can for other documents, but also enables it to wipe all annotations in the document by clearing the layer's data trees.