bonjour-hap 3.6.5 → 3.6.6-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -112,6 +112,10 @@ Options are the same as given in the `browser.find` function.
112
112
 
113
113
  Emitted every time a new service is found that matches the browser.
114
114
 
115
+ #### `Event: update`
116
+
117
+ Emitted every time an update is received for existing service is found that matches the browser.
118
+
115
119
  #### `Event: down`
116
120
 
117
121
  Emitted every time an existing service emmits a goodbye message.
@@ -136,7 +140,7 @@ Broadcast the query again.
136
140
 
137
141
  #### `Event: up`
138
142
 
139
- Emitted when the service is up.
143
+ Emitted when the service is up, and if the txt record of the service is updated `service.updateTxt(object)`.
140
144
 
141
145
  #### `Event: error`
142
146
 
package/lib/Browser.js CHANGED
@@ -82,8 +82,11 @@ Browser.prototype.start = function () {
82
82
  if (matches.length === 0) return
83
83
 
84
84
  matches.forEach(function (service) {
85
- if (self._serviceMap[service.fqdn]) return // ignore already registered services
86
- self._addService(service)
85
+ if (self._serviceMap[service.fqdn]) {
86
+ self._updateService(service)
87
+ } else {
88
+ self._addService(service)
89
+ }
87
90
  })
88
91
  })
89
92
  }
@@ -109,6 +112,21 @@ Browser.prototype._addService = function (service) {
109
112
  this.emit('up', service)
110
113
  }
111
114
 
115
+ Browser.prototype._updateService = function (service) {
116
+ let cachedService, index
117
+ this.services.some(function (s, i) {
118
+ if (dnsEqual(s.fqdn, service.fqdn)) {
119
+ cachedService = s
120
+ index = i
121
+ return true
122
+ }
123
+ return false
124
+ })
125
+ if (!cachedService) return
126
+ this.services[index] = service
127
+ this.emit('update', service)
128
+ }
129
+
112
130
  Browser.prototype._removeService = function (fqdn) {
113
131
  let service, index
114
132
  this.services.some(function (s, i) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonjour-hap",
3
- "version": "3.6.5",
3
+ "version": "3.6.6-beta.0",
4
4
  "description": "A Bonjour/Zeroconf implementation in pure JavaScript (for HAP)",
5
5
  "main": "index.js",
6
6
  "author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)",