ToolTalk User's Guide

Updating Message Patterns with the Current Session or File

To update your message patterns with the session or file in which you are currently interested, join the session or file.

Joining the Default Session

When you join a session, the ToolTalk service updates your message pattern with the sessid. For example, if you have declared a ptype or registered a message pattern that specifies TT_SESSION or TT_FILE_IN_SESSION, use tt_session_join to join the default session. The following code sample shows how to join the default session.

	/*
	 * Join the default session
	 */

	tt_session_join(tt_default_session());

Table 9–2 lists the ToolTalk functions you use to join the session in which you are interested.

Table 9–2 ToolTalk Functions for Joining Default Sessions

Return Type 

ToolTalk Function 

Description 

char *

tt_default_session(void)

Return default session id 

Tt_status

tt_default_session_set(const char *sessid)

Set default session 

char *

tt_initial_session(void)

Return initial session id 

Tt_status

tt_session_join(const char *sessid)

Join this session  

Tt_status

tt_session_quit(const char *sessid)

Quit session 

Once your patterns are updated, you will begin to receive messages scoped to the session you joined.


Note –

If you had previously joined a session and then registered a ptype or a new message pattern, you must again join the same session or a new session to update your pattern before you will receive messages that match your new pattern.


When you no longer want to receive messages that reference the default session, use the tt_session_quit() function. This function removes the sessid from your session-scoped message patterns.

Joining Multiple Sessions

When you join multiple sessions, you will automatically get responses to requests and point-to-point messages but you will not get notices unless you explicitly join the new session. The following code sample shows how to join the multiple sessions.

tt_default_session_set(new_session_identifier);
tt_open();
tt_session_join(new_session);

In order to effectively use multiple sessions, you must store the session ids of the sessions in which you are interested in order to pass these identifiers to tt_default_session_set prior to opening a new session with tt_open; that is, you need to place the values (which ttsession stores in the environment variable _SUN_TT_SESSION) in a file on the system so that other ToolTalk clients can access the value of a session id contained in that file and use it to open the non-default session. For example, you can store the session ids in a “well-known” file and then send a file-scoped message (indicating this file) to all clients which have registered an appropriate pattern. The client will then know to open the scoped-to file, read one or more session ids from it, and use these session ids (with tt_open) to open a non-default session. An alternative method is advertising the session ids by means of, for example, a name service or a third-party database.


Note –

How ttsession session ids are stored and passed to interested clients is beyond the scope of the ToolTalk protocol and must be determined based on the architecture of the system.


Joining Files of Interest

When you join a file, the ToolTalk service automatically adds the name of the file to your file-scoped message patterns. For example, if you have declared a process type or registered a message pattern that specifies TT_FILE or TT_FILE_IN_SESSION, use the tt_file_join function() to join files of interested. Table 9–3 lists the ToolTalk functions you use to express your interest in specific files.

Table 9–3 ToolTalk Functions for Joining Files of Interest

Return Type 

ToolTalk Function 

Description 

char *

tt_default_file(void)

Join default file 

Tt_status

tt_default_file_set(const char *docid)

Set default file 

Tt_status

tt_file_join(const char *filepath)

Join this file 

Tt_status

tt_file_quit(const char *filepath)

Quit file 

When you no longer want to receive messages that reference the file, use the tt_file_quit() function to remove the file name from your file-scoped message patterns.