forked from TheThingSystem/node_avahi_pub
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.coffee
More file actions
29 lines (24 loc) · 721 Bytes
/
example.coffee
File metadata and controls
29 lines (24 loc) · 721 Bytes
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
28
29
avahi = require('./avahi_pub')
# Validate that avahi is supported on this platform (avahi is linux-only)
if avahi.isSupported()
console.log "Node Avahi Pub is supported"
# Advertise a _construct._tcp service named MyService with txtdata on port 1337
service = avahi.publish
name: "MyService"
type: "_construct._tcp"
data: "myData"
port: 1337
service2 = avahi.publish
name: "Another Freaking Service"
type: "_stuff._tcp"
data: "myData"
port: 5555
# Stop advertising that service 4 seconds later
remove = ->
service.remove()
service2.remove()
avahi.kill()
console.log "all done!"
setTimeout remove, 8000
else
console.log "Node Avahi Pub is not supported"