TipcSrvMonClientNamesSetWatch start or stop watching RTclient names
srv
connection handle to RTserver
watch_status
new watch status (TRUE
to start watching, FALSE
to stop watching)
TRUE
if the RTclient names watch status was successfully set, FALSE
otherwise.
If TipcSrvMonClientNamesSetWatch fails, it returns FALSE
and sets the global SmartSockets error number to one of:
TipcSrvMonClientNamesSetWatch sets whether this RTclient is watching the RTclient names in the current project that match the value of the Monitor_Scope option. TipcSrvMonClientNamesSetWatch saves the watch status and sends a MON_CLIENT_NAMES_SET_WATCH message to RTserver. The watch status controls whether the RTclient receives a MON_CLIENT_NAMES_STATUS message each time an RTclient is created or destroyed. An RTclient is considered created when it connects to RTserver. An RTclient is considered destroyed when it disconnects from RTserver. The watch status is saved internally so the RTclient can automatically resume watching all appropriate categories if RTclient has to reconnect to RTserver.
The Srv_Client_Names_Min_Msgs
option, described in the TIBCO SmartSockets User’s Guide, controls the number of fields returned in the MON_CLIENT_NAMES_STATUS
message. If Srv_Client_Names_Min_Msgs
is set to FALSE, each MON_CLIENT_NAMES_STATUS
message contains the following fields:
"
ident
:
user
@
node
"
(such as "Primary_RTclient: ssuser@workstation1"
)""
if not applicable) ""
if not applicable)disconnect_client_on_nak_failure
was set to TRUE).
In addition to sending a MON_CLIENT_NAMES_STATUS
message each time an RTclient is created or destroyed, RTserver also sends an initial MON_CLIENT_NAMES_STATUS
message when the watch status is set to TRUE, so that the RTclient does not have to wait for the next RTclient name change to receive the first MON_CLIENT_NAMES_STATUS
message. User’s can limit the size of subsequent MON_CLIENT_NAMES_STATUS
messages to only the name of the RTclient created or destroyed and the reason for the destroy by setting the RTserver option Srv_Client_Names_Min_Msgs
to TRUE
.
To determine if this RTclient is watching RTclient names, use TipcSrvMonClientNamesGetWatch. To poll once for the RTclient names, use TipcSrvMonClientNamesPoll.
TipcSrvMonClientNamesSetWatch sends a MON_CLIENT_NAMES_SET_WATCH message to RTserver, but does not explicitly flush the message. See TipcSrvConnGetAutoFlushSize for more information on message buffering.
TipcSrvMonClientNamesGetWatch, TipcSrvMonClientNamesPoll
This example uses TipcSrvMonClientNamesSetWatch to start watching RTclient names and creates a callback to process the incoming MON_CLIENT_NAMES_STATUS messages:
/* =============================================================== */
/*..process_mon_client_names_status -- process a MON_CLIENT_NAMES_STATUS message */
void T_ENTRY process_mon_client_names_status(conn, data, arg) T_IPC_CONN conn; T_IPC_CONN_PROCESS_CB_DATA data; T_CB_ARG arg; { T_STR *client_names; T_INT4 num_client_names; T_STR *info_strs; T_STR *server_names; T_STR created_client; T_STR destroyed_client; T_STR reason; T_INT4 counter;/* must set current field first */
if (!TipcMsgSetCurrent(data->msg, 0)) {return
; /* error */
}/* get the fields from the message */
/* client_names, info_strs, and server_names contains the same
number of elements */
if (!TipcMsgNextStrArray(data->msg, &client_names, &num_client_names) || !TipcMsgNextStrArray(data->msg, &info_strs, &num_client_names) || !TipcMsgNextStrArray(data->msg, &server_names, &num_client_names) || !TipcMsgNextStr(data->msg, &created_client) || !TipcMsgNextStr(data->msg, &destroyed_client)) {return
; /* error */
} TutOut("Got CLIENT_NAMES status.\n"); for (counter = 0; counter < num_client_names; counter++) { TutOut("client_names[%d] = %s\n", counter, client_names[counter]); TutOut("info_strs[%d] = %s\n", counter, info_strs[counter]); TutOut("server_names[%d] = %s\n", counter, server_names[counter]); } TutOut("created RTclient = %s\n", created_client); TutOut("destroyed RTclient = %s\n", destroyed_client); if (TipcMsgNextStr(data->msg, &reason)) { TutOut("reason for disconnect = %s\n", reason); } }/* process_mon_client_names_status */
/* =========================================================== */
/*...code from calling function is below */
T_IPC_MT mt; if (!TipcSrvMonClientNamesSetWatch(srv, TRUE)) {
return
; /* error */
} mt = TipcMtLookupByNum(T_MT_MON_CLIENT_NAMES_STATUS); if (mt == NULL) {
return
; /* error */
} if (TipcSrvConnProcessCbCreate(srv, mt, process_mon_client_names_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 |