Registering Services for Autostart

For some messages, you might want a service process to get autostarted as necessary. When the message is sent and the process is not available, the ToolTalk service starts the process and queues the message.

To set this up, you need to register your application class with what ToolTalk calls a "ptype," a process type (refer to the ToolTalk Programmer's Guide). For example, you might have a file called myapp.ptype that contains:

ptype USR_MY_APP
{
start "/usr/bin/X11/myApp";
observe: session load_file() => start;
}

This indicates that the message "load_file" is observed by a process typed "USR_MY_APP" and that when a "load_file" message is sent, the ToolTalk service should execute "/usr/bin/X11/myApp."

Then, instantiate the VkMsgApp object in the myApp application as follows:

VkMsgApp *myApp = new VkMsgApp("MyApp", &argc, argv, NULL, 0,
"USR_MY_APP");

Finally, when you install your application, register this information in the static ToolTalk config file by executing:

${ToolTalkBin}/tt_type_comp -dsystem myapp.ptype
kill -USR2 ${TTSessionPid}

This adds the contents of myapp.ptype to the system config file, and tells all existing ttsession processes to update their configurations.

Registering an action without the pattern

When you express message patterns in a ptype, do not register the pattern in your application. Otherwise, your message handler will be called twice. To register an action, but not register the corresponding pattern, use createAction() instead of addAction().