Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ function probe (mdns, service, cb) {
// just silently ignore it and retry as we normally would
sent = true
timer = setTimeout(++retries < 3 ? send : done, 250)
timer.unref()

// Call this function twice to make bonjour compatible with client side Electron
timer.unref && timer.unref()
})
}

Expand Down Expand Up @@ -132,24 +134,25 @@ function announce (server, service) {

server.register(packet)

;(function broadcast () {
// abort if the service have or is being stopped in the meantime
if (!service._activated || service._destroyed) return

server.mdns.respond(packet, function () {
// This function will optionally be called with an error object. We'll
// just silently ignore it and retry as we normally would
if (!service.published) {
service._activated = true
service.published = true
service.emit('up')
}
delay = delay * REANNOUNCE_FACTOR
if (delay < REANNOUNCE_MAX_MS && !service._destroyed) {
setTimeout(broadcast, delay).unref()
}
})
})()
; (function broadcast () {
// abort if the service have or is being stopped in the meantime
if (!service._activated || service._destroyed) return

server.mdns.respond(packet, function () {
// This function will optionally be called with an error object. We'll
// just silently ignore it and retry as we normally would
if (!service.published) {
service._activated = true
service.published = true
service.emit('up')
}
delay = delay * REANNOUNCE_FACTOR
if (delay < REANNOUNCE_MAX_MS && !service._destroyed) {
// Call this function twice to make bonjour compatible with client side Electron
setTimeout(broadcast, delay).unref && setTimeout(broadcast, delay).unref()
}
})
})()
}

/**
Expand Down
Loading