TipcSrvMonClientSubscribeSetWatch start or stop watching the subjects that an RTclient is subscribing to
T_BOOL TipcSrvMonClientSubscribeSetWatch(srv
,client_name
,watch_status
) T_IPC_SRVsrv
; T_STRclient_name
; T_BOOLwatch_status
;
srv
connection handle to RTserver
client_name
name of RTclient to set watch status for (wildcard names allowed, or use T_IPC_MON_ALL to indicate a watch of all RTclients matching the value of Monitor_Scope)
watch_status
new watch status (TRUE
to start watching, FALSE
to stop watching)
TRUE
if the RTclient subscribe watch status was successfully set, FALSE
otherwise.
If TipcSrvMonClientSubscribeSetWatch fails, it returns FALSE
and sets the global SmartSockets error number to one of:
TipcSrvMonClientSubscribeSetWatch sets whether this RTclient is watching the subjects that the client_name
RTclient is subscribing to. The client_name
argument can be the unique subject name of a single RTclient, a wildcarded subject name to match many RTclients, or T_IPC_MON_ALL to poll all RTclients in the project that match the value of the Monitor_Scope option. TipcSrvMonClientSubscribeSetWatch saves the watch status and sends a MON_CLIENT_SUBSCRIBE_SET_WATCH message to RTserver. The watch status controls whether the RTclient receives a MON_CLIENT_SUBSCRIBE_STATUS message each time the watched RTclient starts or stops subscribing to a subject. The watch status is saved internally so the RTclient can automatically resume watching all appropriate categories if RTclient has to reconnect to RTserver.
Each MON_CLIENT_SUBSCRIBE_STATUS message contains four fields:
""
if not applicable) ""
if not applicable)
In addition to sending a MON_CLIENT_SUBSCRIBE_STATUS message each time the watched RTclient starts or stops subscribing to a subject, RTserver also sends an initial MON_CLIENT_SUBSCRIBE_STATUS message (or many messages if a wildcard or T_IPC_MON_ALL is used) when the watch status is set to TRUE
, so that the RTclient does not have to wait for the next subscribed subject change to receive the first MON_CLIENT_SUBSCRIBE_STATUS message.
To determine if this RTclient is watching the subjects that an RTclient is subscribing to, use TipcSrvMonClientSubscribeGetWatch. To poll once for the subjects that an RTclient is subscribing to, use TipcSrvMonClientSubscribePoll.
For an example of how MON_CLIENT_SUBSCRIBE_STATUS messages can be used, see the RTmon GDI Watch Client Subjects window.
TipcSrvMonClientSubscribeSetWatch sends a MON_CLIENT_SUBSCRIBE_SET_WATCH message to RTserver, but does not explicitly flush the message. See TipcSrvConnGetAutoFlushSize for more information on message buffering.
There is no initial status message if the RTclient named client_name
does not exist.
TipcSrvMonClientSubscribeGetWatch, TipcSrvMonClientSubscribePoll
This example uses TipcSrvMonClientSubscribeSetWatch to start watching the subjects being subscribed to by the primary RTclient and creates a callback to process the incoming MON_CLIENT_SUBSCRIBE_STATUS messages:
/* =============================================================== */
/*..process_mon_client_subscribe_status -- process a MON_CLIENT_SUBSCRIBE_STATUS message */
void T_ENTRY process_mon_client_subscribe_status(conn, data, arg) T_IPC_CONN conn; T_IPC_CONN_PROCESS_CB_DATA data; T_CB_ARG arg; { T_STR client_name; T_STR *subscribe_subject_names; T_INT4 num_subscribe_subject_names; T_STR start_subject; T_STR stop_subject; T_INT4 counter;/* must set current field first */
if (!TipcMsgSetCurrent(data->msg, 0)) {return
; /* error */
}/* get the fields from the message */
if (!TipcMsgNextStr(data->msg, &client_name) || !TipcMsgNextStrArray(data->msg, &subscribe_subject_names, &num_subscribe_subject_names) || !TipcMsgNextStr(data->msg, &start_subject) || !TipcMsgNextStr(data->msg, &stop_subject)) {return
; /* error */
} TutOut("Got CLIENT_SUBSCRIBE status.\n"); TutOut("RTclient name = %s\n", client_name); for (counter = 0; counter < num_subscribe_subject_names; counter++) { TutOut("subscribe_subject_names[%d] = %s\n", counter, subscribe_subject_names[counter]); } TutOut("start subject = %s\n", start_subject); TutOut("stop subject = %s\n", stop_subject); }/* process_mon_client_subscribe_status */
/* =========================================================== */
/*...code from calling function is below */
T_IPC_MT mt; if (!TipcSrvMonClientSubscribeSetWatch(srv, "primary", TRUE)) {
return
; /* error */
} mt = TipcMtLookupByNum(T_MT_MON_CLIENT_SUBSCRIBE_STATUS); if (mt == NULL) {
return
; /* error */
} if (TipcSrvConnProcessCbCreate(srv, mt, process_mon_client_subscribe_status, NULL) == NULL) {return
; /* error */
}/* At this point TipcSrvConnMainLoop can be used to read and process messages. */
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |