1.start thread1, regist notification stream1 by confd_register_notification_stream() and send event notification by confd_notification_send().
i start thread2 and use the confd_notifications_connect2() and confd_read_notification() to subscriber the stream1 (simulate one subscriber user session )and reveived the related notification from the stream1.
how the thread1 to get the subscriber status(such as start or stop) of the thread2 subscriber user session?
(such as: if thread2 start, thread1 could know the stream1 subscriber session is ready, if thread2 exit, the stream1 subscriber is not ready.)
The source code for the confd_load tool comes with ConfD:
`$CONFD_DIR/src/confd/tools/confd_load.c
You can also use the confd_cmd tool that can use maapi_get_objects() to get the list: $ confd_cmd -dd -o -c 'traverse_list "/netconf-state/streams/stream{interface}/subscriber"'
The source code for the confd_cmd tool can be found in the same folder as the confd_load tool. $CONFD_DIR/src/confd/tools/confd_cmd.c
ok,
Is there other event mechnism automatically ? when thread2 start and subscriber this stream, thread1 can get it right now. when the subscriber is exist(thread2 exist), thread1 can know it right now.
for below case:
1.start thread1, regist notification stream1 by confd_register_notification_stream() and send event notification by confd_notification_send().
i start thread2 and use the confd_notifications_connect2() and confd_read_notification() to subscriber the stream1 (simulate one subscriber user session )and reveived the related notification from the stream1
Do you mean getting a notification when someone register for a NETCONF stream notification using the ConfD event notification API?
If so I believe that you can’t subscribe to those changes, and that you need to poll.
Example using the confd_cmd tool:
ecode=1; while [ $ecode -ne 0 ]; do sleep .5; confd_cmd -o -c "mget /netconf-state/streams/stream{interface}/subscriber{1}/session-id" > /dev/null; ecode=$?; done;
thanks for your response.
it seems need application code to do subscriber status polling.
for the standard notificaiton subscriber method(use netconf protocol to subscriber), we can get the user session status(START or STOP) by notificaiton event(CONFD_NOTIF_USER_SESSION - Whenever a user session is started or stopped).
Can we have some methods to get the user session status automatically like the above CONFD_NOTIF_USER_SESSION event.(attention: we use confd_notifications_connect2() and confd_read_notification() API to subscriber NETCONF stream)
thanks for your help.
Can we have some methods to get the user session status automatically like the above CONFD_NOTIF_USER_SESSION event.(attention: we use confd_notifications_connect2() and confd_read_notification() API to subscriber NETCONF stream)
Instead, when your notification stream subscriber application registers using confd_notifications_connect2(), the notification stream subscriber application can at the same time add itself to a list of subscribers in the CDB operational datastore by, for example, reusing the stream subscriber list from the $CONFD_DIR/src/confd/yang/tailf-netconf-monitoring.yang model.
Then you do a cdb_oper_subscribe() to the subscriber list from your application that send notifications.