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

Method probe

modules/io/dnssd/dnssd.js:553–582  ·  view source on GitHub ↗
(claim)

Source from the content-addressed store, hash-verified

551 if tie...
552 */
553 probe(claim) {
554 delete claim.initial;
555 trace(`probe for ${claim.host}\n`);
556 claim.timer = Timer.repeat(id => {
557 if (claim.probing < 0) {
558 claim?.onError();
559 this.unclaim(claim);
560 return;
561 }
562
563 if (4 === claim.probing) {
564 trace(`probe claimed ${claim.host}\n`);
565
566 Timer.clear(id);
567 delete claim.timer;
568 delete claim.probing;
569 delete claim.probeAttempt;
570
571 claim.onReady?.();
572 return;
573 }
574
575 trace(`probe ${claim.probing}\n`);
576 const reply = new Serializer({query: true, opcode: DNS.OPCODE.QUERY, authoritative: true});
577 reply.add(DNS.SECTION.QUESTION, claim.host + "." + LOCAL, DNS.RR.ANY, DNS.CLASS.IN | DNSSD.UNICAST); // question for DNS.RR.A, unicast response requested
578 reply.add(DNS.SECTION.ANSWER, claim.host + "." + LOCAL, DNS.RR.A, DNS.CLASS.IN | DNSSD.FLUSH, 120, Net.get("IP")); // authoritative answer for DNS.RR.A
579 this.write(reply.build());
580 claim.probing += 1;
581 }, 250, 10); //@@ random initial delay
582 }
583
584 static {
585 this.prototype[Symbol.dispose] = this.prototype.close;

Callers 2

claimMethod · 0.95
setupRtcMethod · 0.45

Calls 9

unclaimMethod · 0.95
addMethod · 0.95
writeMethod · 0.95
buildMethod · 0.95
repeatMethod · 0.80
onErrorMethod · 0.65
onReadyMethod · 0.65
getMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected