Jump to content
OpenSplice DDS Forum
Sign in to follow this  
bdavis

dataWriter listener

Recommended Posts

static void cb (void *listener_data,
                DDS_DataWriter writer,
                const DDS_PublicationMatchedStatus *status)
{
   printf("i am in the publication matched callback\n");
}

static void ll (void *listener_data,
                DDS_DataWriter writer,
                const DDS_LivelinessLostStatus *status)
{
   printf("i am in the liveleness lost callback\n");
}
 

 

......................................................

 

 

// Create the Publisher's in the DDS Domain.
   message_Publisher = createPublisher(domainParticipant);

   // Request a Writer from the the Publisher.
   message_DataWriter = createDataWriter(message_Publisher, messageTopic);


  /* Allocate the DataReaderListener interface. */
    msgListener = DDS_DataWriterListener__alloc();
    checkHandle(msgListener, "DDS_DataWriterListener__alloc");

    /* Fill the listener_data with pointers to all entities needed by the Listener implementation. */
    msgListener->listener_data = 0;

    /* Assign the function pointer attributes to their implementation functions. */
    msgListener->on_publication_matched = cb;
    msgListener->on_offered_deadline_missed = 0;
    msgListener->on_offered_incompatible_qos = 0;
    msgListener->on_liveliness_lost = ll;

    /* Attach the DataReaderListener to the DataReader, only enabling the data_available event. */
    int status = DDS_DataWriter_set_listener(message_DataWriter, msgListener, DDS_PUBLICATION_MATCHED_STATUS );
    checkStatus(status, "DDS_DataWriter_set_listener");
 

 

Above is the code I added to the helloworld example.  Plus made both the sender and reciever run forever.

 

I run the publisher task and the subscriber task.  The callback is called one time.  As expected. 

I ctrl-c the subscriber task, and I get another DDS_PUBLICATION_MATCHED_STATUS callback.

 

My expectation is I would recieve DDS_LIVELENESS_LOSS callback.  I have used each constant in the set_listener function, and the two or'd together.

 

The only callback I recieve is DDS_PUBLICATION_MATCHED_STATUS, and I get one when the subscriber starts and another when it exits.

 

What am I doing wrong ?

 

 

regards,

bud davis

 

 

 

Share this post


Link to post
Share on other sites

Allow me to answer  my own question.

 

along with the callback comes some status:

 

total_count

current_count

current_count_change

 

which makes it obvious why you get a call on a subscribe and a call on the un-subscribe.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×