Common Desktop Environment: ToolTalk Messaging Overview

Tasks Every ToolTalk-aware Application Needs to Perform

There are a number of tasks every ToolTalk-aware application needs to perform, including:

This section provides examples of the ToolTalk code you need to include in your application so that it can perform these tasks.

Note -

The code snippets used in this section are taken from the CoEd.C file. This file contains the general commands any application needs to perform that are not specific to any particular application. See Appendix B, The CoEd Demonstration Program for the detailed source code.

Initializing the Toolkit

Your application needs to initialize and register with the initial ToolTalk session. To do so, it first needs to obtain a process identifier (procid). The following code snippet shows how to obtain a procid and how to initialize the toolkit.

// Obtain process identifier
    int myTtFd; //
Initialize toolkit and create a ToolTalk communication endpoint
    char *myProcID = ttdt_open( &myTtFd, ToolName, "SunSoft", "%I", 1 );

Caution - Caution -

Your application must call ttdt_open before any other calls are made; otherwise, errors may occur.

Joining the ToolTalk Session and Registering Message Patterns

Before your application can receive messages, it must join a ToolTalk session and register the message patterns that are to be matched.

// Join a ToolTalk session and register patterns and default callbacks
           sessPats = ttdt_session_join( 0, 0, session_shell, this, 1 );

Adding the ToolTalk Service to Event Loop

Your application also needs to add the ToolTalk service to its event loop.

// Process ToolTalk events for Xt Clients
      XtAppAddInput( myContext, myTtFd, (XtPointer)XtInputReadMask, tk_Xt_input_handler,
              myProcID );