MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / monitorTask

Method monitorTask

modules/network/mdns/mdns.js:165–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163 }
164 }
165 monitorTask() {
166 const mdns = this.mdns;
167 switch (this.state) {
168 case 0:
169 case 1:
170 case 2:
171 case 3:
172 const query = new Serializer({query: true, opcode: DNS.OPCODE.QUERY});
173
174 query.add(DNS.SECTION.QUESTION, this.service, DNS.RR.PTR, DNS.CLASS.IN | ((0 == this.state) ? MDNS.UNICAST : 0));
175
176 for (let i = 0; i < this.length; i++)
177 query.add(DNS.SECTION.ANSWER, this.service, DNS.RR.PTR, DNS.CLASS.IN, TTL, this[i].name + "." + this.service);
178
179 try {
180 mdns.write(MDNS.IP, MDNS.PORT, query.build());
181 }
182 catch {
183 this.timer = Timer.set(mdns.monitorTask.bind(this), 10 * 1000);
184 return;
185 }
186
187 if (this.state < 3) {
188 this.timer = Timer.set(mdns.monitorTask.bind(this), (2 ** this.state) * 1000);
189 this.state += 1;
190 }
191 else
192 this.timer = Timer.set(mdns.monitorTask.bind(this), 30 * 60 * 1000); //@@ calculate based on TTL elapsed (section 5.2 Continuous Multicast DNS Querying)
193 break;
194 }
195 }
196 scanPacket(packet, address) {
197 const answers = packet.answers;
198 let changed, i, j, length;

Callers

nothing calls this directly

Calls 5

addMethod · 0.95
buildMethod · 0.95
writeMethod · 0.65
setMethod · 0.65
bindMethod · 0.45

Tested by

no test coverage detected