ToolTalk User's Guide

3 Message Patterns


Contents of Chapter:
3.1 Message Pattern Attributes
3.2 Scope Attributes
Scoping to a Session Only
Scoping to a File Only
Scoping to a File in a Session
Scoping to a File and/or a Session
Adding Files to Scoped Patterns
3.3 Context Attributes
3.4 Disposition Attributes
This chapter describes how to provide message pattern information to the ToolTalk service. The ToolTalk service uses message patterns to determine message recipients. After receiving a message, the ToolTalk service compares the message to all current message patterns to find a matching pattern. Once a match is made, the message is delivered to the application that registered the message pattern.

You can provide message pattern information to the ToolTalk service using either dynamic or static methods, or both. The method you choose depends on the type of messages you want to receive.

Regardless of the method you choose to provide message patterns to the ToolTalk service, you will want to update these patterns with each current session and file information so that you receive all messages that reference the session or file in which you are interested.

3.1 Message Pattern Attributes

The attributes in your message pattern specify the type of messages you want to receive. Although some attributes are set and have only one value, you can supply multiple values for most of the attributes you add to a pattern.

Table 3-1 provides a complete list of attributes you can put in your message patterns.

Table 3-1 ToolTalk Message Pattern Attributes

All your message patterns must at least specify:

The ToolTalk service compares message attributes to pattern attributes as follows:

3.2 Scope Attributes

You can specify the following types of scopes in your message patterns:

  1. Scope to a session only.

  2. Scope to a file only.

  3. Scope only to a file in a particular session.

  4. Scope to either or both a file and a session.


Note: File scopes are restricted to NFS and UFS file systems; you cannot scope a file across other types of file systems (for example, a tmpfs file system).

Scoping to a Session Only

The type TT_SESSION scopes to a session only. Static session-scoped patterns require an explicit tt_session_join call to set the scope value; dynamic session-scoped patterns can be set with either the tt_session_join call or the tt_pattern_session_add call.


Note: The session specified by these calls must be the default session.

Code Example 3-1 shows a static session-scoped pattern; Code Example 3-2 shows a dynamic session-scoped pattern.

Code Example 3-1 Static Session-Scoped Pattern

Code Example 3-2 Dynamic Session-Scoped Pattern with a File Attribute

Scoping to a File Only

The type TT_FILE scopes to a file only. Code Example 3-3 shows a static file-scoped pattern; Code Example 3-4 shows a dynamic file-scoped pattern.

Code Example 3-3 Static File-Scoped Pattern

Code Example 3-4 Dynamic File-Scoped Pattern

Scoping to a File in a Session

The type TT_FILE_IN_SESSION scopes to the specified file in the specified session only. A pattern with this scope set will only match messages that are scoped to both the file and the session. Code Example 3-5 adds the session and then registers the pattern.

Code Example 3-5 Adding a Session to the TT_FILE_IN_SESSION-Scoped Pattern

Code Example 3-6 registers the pattern and then joins a session.

Code Example 3-6 Joining a Session to Set the Session of a TT_FILE_IN_SESSION-Scoped Pattern

Code Example 3-7 sets the scope value for a static pattern.

Code Example 3-7 Setting the Scope Value for a TT_FILE_IN_SESSION Static Pattern

Scoping to a File and/or a Session

A TT_BOTH-scoped pattern will match messages that are scoped to the file, the session, or the file and the session. However, when you use this scope, you must explicitly make a tt_file_join call; otherwise, the ToolTalk service will only match messages that are scoped to both the file and session of the registered pattern. Code Example 3-8 and Code Example 3-9 show examples of how to use this scope.

Code Example 3-8 A Dynamic Pattern that Uses the TT_BOTH Scope

Code Example 3-9 A Static Pattern that Uses the TT_BOTH Scope

Adding Files to Scoped Patterns

To match TT_SESSION-scoped messages and TT_SESSION-scoped patterns that have the same file attributes, you can add file attributes to TT_SESSION-scoped patterns with the tt_pattern_file_add call, as shown in Code Example 3-10.


Note: The file attribute values do not affect the scope of the pattern.

Code Example 3-10 Adding Two File Attributes to a Session-Scoped Pattern

3.3 Context Attributes

ToolTalk contexts are sets of <name, value> pairs explicitly included in both messages and patterns. ToolTalk contexts allow fine-grain matching.

You can use contexts to associate arbitrary pairs with ToolTalk messages and patterns, and to restrict the set of possible recipients of a message. One common use of the restricted pattern matching provided by ToolTalk context attributes is to create sub-sessions. For example, two different programs could be debugged simultaneously with tools such as a browser, an editor, a debugger, and a configuration manager active for each program. The message and pattern context slots for each set of tools contain different values; the normal ToolTalk pattern matching of these values keep the two sub-sessions separate.

Another use for the restricted pattern matching provided by ToolTalk context attributes is to provide information in environment variables and command line arguments to tools started by the ToolTalk service.

3.4 Disposition Attributes

Disposition attributes instruct the ToolTalk service how to handle messages to your application if an instance of the application is not currently running.

The disposition value specified in the static type definition of a pattern is the default disposition; however, if the message deposition specifies the handler ptype the default disposition value is over-ridden. For example, a message disposition specifies a static type definition for the ptype UWriteIt which includes the message signature Display. This message signature does not match any of the static signatures in the pattern. The ToolTalk service will follow the instructions for the disposition set in the message; for example, if the message disposition is TT_START and the UWriteIt ptype specifies a start string, the ToolTalk service will start an instance of the application if one is not running.



Generated with CERN WebMaker