Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
D.  Frequently Asked Questions Questions What information does a session id contain?  Previous   Contents   Next 
   
 

Is there a standard way to announce that a new program has joined a session?

Broadcast a notice message to notify interested processes when a new process joins a session. To observe notice messages, a process that want to be notified if a new process joins a session must register patterns to observe these notices.


Note - The Desktop Services "Started" message was developed for this purpose.


Where is my message going?

Use the -t (trace mode) at start-up to observe how ttsession processes each message you send. You can also toggle the trace mode on and off by sending ttsession a USR1 signal; for example:

kill -USR1 <ttsession_pid>

Alternatively, you can use the ttsnoop and/or tttrace utilities to monitor a message.

What is the basic flow of a message?

There are two types of message flow:

  • Session-Scoped

  • File-Scoped

Session-Scoped Message Flow

The basic flow of a session-scoped message is as follows:

  1. The client builds request message and calls tt_message_send.

  2. ttsession finds a handler.

    The environment variable TT_TOKEN is set by ttsession when it starts the handler.

  3. The handler starts up and calls tt_open and tt_fd to establish communication to ttsession.

  4. The handler declares its ptype to ttsession.

  5. ttsession changes all the static patterns for the ptype into dynamic patterns.

    At this point, the patterns are not active because the handler has not yet joined the session.

  6. The handler joins session, activating patterns.

  7. ttsession notifies the handler that a message is queued.

  8. The handler notices activity on the file descriptor and calls tt_message_receive to retrieve the message.

    If the message returned by tt_message_receive has the status TT_WRN_START_MESSAGE, the ToolTalk service started the process to deliver the message. In this case, messages for the ptype are blocked until the process either replies, rejects, or fails the message (even if it is a notice), or calls tt_message_accept.

  9. The handler performs the requested operation.

  10. The handler returns a reply to request.

  11. ttsession notifies the client that a (reply) message for it is in the queue.

    The client's file descriptor is activated.


    Note - The client actually receives a message every time its request message changes state.


  12. The client calls tt_message_receive to retrieve the result.

File-Scoped Message Flow

The basic flow of a file-scoped message is as follows:

  1. A file-scoped pattern is registered.

    libtt notifies the database server about the file and the session in which it is registering the pattern.

  2. libtt checks with the database server to find all the sessions that have clients who have registered interest in the specified file.

    • For notices, it communicates with all these sessions directly.

    • For requests, it notifies its session about the message and the list of other sessions involved.

  3. The sessions communicate amongst each other to find a handler.

What happens when a message arrives to my application?

When a message arrives to your application, the following occurs:

  1. The file descriptor becomes active.

  2. The Xt main loop breaks out of its select and calls the function registered by the XtAppAddInput call.

  3. The registered function calls tt_message_receive.

    The message is read in and any callbacks associated with the message are run.

  4. The message callback returns.

    • If the message callback returns TT_CALLBACK_PROCESSED, tt_message_receive returns a value of null to the input callback.

    • If the message callback returns TT_CALLBACK_CONTINUE, a Tt_message handle for the message is returned.

  5. The input callback continues with any other processing.

 
 
 
  Previous   Contents   Next