| 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; |