JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
ToolTalk User's Guide
search filter icon
search icon

Document Information

Preface

1.  Introducing the ToolTalk Service

2.  An Overview of the ToolTalk Service

3.  Message Patterns

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

8.  Sending Messages

9.  Dynamic Message Patterns

10.  Static Message Patterns

11.  Receiving Messages

Retrieving Messages

Identifying and Processing Messages Easily

Recognizing and Handling Replies Easily

Checking Message Status

Examining Messages

Callback Routines

Callbacks for Messages Addressed to Handlers

Attaching Callbacks to Static Patterns

Handling Requests

Replying to Requests

Rejecting or Failing a Request

Rejecting a Request

Failing a Request

Observing Offers

Destroying Messages

12.  Objects

13.  Managing Information Storage

14.  Handling Errors

A.  Migrating from the Classing Engine to the ToolTalk Types Database

B.  A Simple Demonstration of How the ToolTalk Service Works

C.  The ToolTalk Standard Message Sets

D.  Frequently Asked Questions

Glossary

Index

Retrieving Messages

When a message arrives for your process, the ToolTalk-supplied file descriptor becomes active. When notified of the active state of the file descriptor, your process must call tt_message_receive to get a handle for the incoming message.

illustrates how to receive a message.

Example 11-1 Receiving a Message

/*
 * When a ToolTalk message is available, receive it; if it's a
 * ttsample1_value message, update the gauge with the new value.
 */
void
receive_tt_message()
{
    Tt_message msg_in;
    int mark;
    int val_in;

    msg_in = tt_message_receive();

    /*
     * It's possible that the file descriptor would become active
     * even though ToolTalk doesn't really have a message for us.
     * The returned message handle is NULL in this case.
     */

    if (msg_in == NULL) return;

Handles for messages remain constant. For example, when a process sends a message, both the message and any replies to the message have the same handle as the sent message. is an example of how you can check the message state for TT_HANDLED.

Example 11-2 Code Checking the Message State

Tt_message m, n;
m = tt_message_create();
...
tt_message_send(m);

... wait around for tt_fd to become active

n = tt_message_receive();
if (m == n) {
    /* This is the reply to the message we sent */
    if (TT_HANDLED == tt_message_state(m) ) {
            /* The receiver has handled the message so we can go
on */
            ...
    }
} else {
    /* This is a new message coming in */
)

Identifying and Processing Messages Easily

To easily identify and process messages received by you:

Recognizing and Handling Replies Easily

To easily recognize and handle replies to messages sent by you: