forked from TheThingSystem/node_avahi_pub
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
27 lines (20 loc) · 753 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var bindings = require('bindings')('avahi_pub.node')
, interval = null;
module.exports =
{ publish : function(opts) {
var service;
if (!module.exports.isSupported()) throw new Error('avahi_pub not supported on this platform');
service = bindings.publish(opts);
bindings.poll();
return service;
}
, isSupported : function() {
return (require('os').platform() === 'linux');
}
, kill : function() {
clearInterval(interval);
interval = null;
}
};
bindings.init();
if (module.exports.isSupported()) interval = setInterval(bindings.poll, 1000);