agnat/node_mdns — Issue #23: Re-advertsing a record with a changed txtRecord doesn't work as expected.
Author: dtyree77
Created: 2012-02-14 21:27:07+00:00
State: open

Hi,

I'm trying to use your node_mdns module to advertise not only the existence of a server but specifics about the service.

So imagine for a moment that I wanted to advertise the list of current logged in users on my linux system, and when it changed I wanted to update the txtRecord with a current list of logged in users:

And every time my list of users changed I did the following:

if(mdnsAd!=null){
mdnsAd.stop();
}
var currentUsers = Users.loggedIn();
var now = new Date();

mdns.createAdvertisement(
mdns.tcp('user-watch'), config.port, { txtRecord: { users: currentUsers, updatedAt: now }},function(err,service){
mdnsAd = service;
mdnsAd.start();
});

Well what happens is it seems like the first advertisement I did, regardless of calling stop on it, is used from there on out. So if user 'A' was logged in the first time I created an advertisment, and then user 'B' logged in, I would breifly get an advertisement containing 'A,B', but then the advertisement reverts back to 'A', and has the updatedAt set to the first advertisement's timestamp.

Is this expected behavior?