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.
Example 11–1 illustrates how to receive a message.
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. Example 11–2 is an example of how
you can check the message state for TT_HANDLED
.
To easily identify and process messages received by you:
Add a callback to a dynamic pattern with tt_pattern_callback_add. When you retrieve the message, the ToolTalk service will invoke any message or pattern callbacks. See Chapter 9, Dynamic Message Patterns for more information on placing callbacks on patterns.
Retrieve the message's opnum if you are receiving messages that match your ptype message patterns.
To easily recognize and handle replies to messages sent by you:
Place specific callbacks on requests before you send them with tt_message_callback_add. See Chapter 8, Sending Messages for more information on placing callbacks on messages.
Compare the handle of the message you sent with the message you just received. The handles will be the same if the message is a reply.