1. Introducing the ToolTalk Service
2. An Overview of the ToolTalk Service
4. Setting Up and Maintaining the ToolTalk Processes
5. Maintaining Application Information
6. Maintaining Files and Objects Referenced in ToolTalk Messages
7. Participating in ToolTalk Sessions
Updating Message Patterns with the Current Session or File
13. Managing Information Storage
A. Migrating from the Classing Engine to the ToolTalk Types Database
B. A Simple Demonstration of How the ToolTalk Service Works
To create and register a dynamic message pattern, you allocate a new pattern object, fill in the proper information, and register it. When you are done with the pattern (that is, when you are no longer interested in messages that match it), either unregister or destroy the pattern. You can register and unregister dynamic message patterns as needed.
The ToolTalk functions used to create, register, and unregister dynamic message patterns are listed in .
Table 9-1 Functions for Creating, Updating, and Deleting Message Patterns
|
Note - The return type for all functions except tt_pattern_create is Tt_status; tt_pattern_create returns Tt_pattern.
To create message patterns, use the tt_pattern_create function. You can use this function to get a handle or opaque pointer to a new pattern object, and then use this handle on succeeding calls to reference the pattern.
To fill in pattern information, use the tt_pattern_attribute_add and tt_pattern_attribute_set calls. You can supply multiple values for each attribute you add to a pattern. The pattern attribute matches a message attribute if any of the values in the pattern match the value in the message. If no value is specified for an attribute, the ToolTalk service assumes that you want any value to match. Some attributes are set and, therefore, can only have one value.
To add a callback routine to your pattern, use the tt_pattern_callback_add function.
Note - Callbacks are called in reverse order of registration (for example, the most recently added callback is called first).
When the ToolTalk service matches a message, it automatically calls your callback routine to examine the message and take appropriate actions. When a message that matches a pattern with a callback is delivered to you, it is processed through the callback routine. When the routine is finished, it returns TT_CALLBACK_PROCESSED and the API objects involved in the operation are freed. You can then use tt_message_destroy to destroy the message, which frees the storage used by the message, as illustrated in the following code sample.
|
To register the completed pattern, use the tt_pattern_register() function. After you register your pattern, you join the sessions or files of interest.
The following code sample creates and registers a pattern.
|
Note - If delivered messages that matched the deleted pattern have not been retrieved by your application (for example, the messages might be queued), the ToolTalk service does not destroy these messages.
To delete a message pattern, use the tt_pattern_destroy() function. This function first unregisters the pattern and then destroys the pattern object.
To stop receiving messages that match a message pattern without destroying the pattern object, use the tt_pattern_unregister() to unregister the pattern.
The ToolTalk service will automatically unregister and destroy all message pattern objects when you call tt_close.