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

Method callback

modules/network/dns/dnsresolverudp.js:84–114  ·  view source on GitHub ↗
(message /*, value, address, port */)

Source from the content-addressed store, hash-verified

82 this.socket.write("224.0.0.251", 5353, packet.build());
83 }
84 callback(message /*, value, address, port */) {
85 if (2 !== message)
86 return;
87
88 const packet = new Parser(this.socket.read(ArrayBuffer));
89 const question = packet.question(0);
90 if (question && (DNS.CLASS.IN !== question.qclass))
91 return;
92 const id = packet.id;
93 for (let i = 0; i < this.requests.length; i++) {
94 const request = this.requests[i];
95 if (id !== request.id)
96 continue;
97
98 for (let j = 0, answers = packet.answers; j < answers; j++) {
99 const answer = packet.answer(j);
100 if (DNS.RR.A !== answer.qtype)
101 continue;
102
103 if ((question && (question.qname.join(".") === request.host)) || (answer.qname.join(".") === request.host)) {
104 this.remove(request.request);
105 return request.onResolved?.call(request.request, answer.rdata);
106 }
107 }
108
109 if (id) {
110 this.remove(request.request);
111 return request.onError?.call(request.request);
112 }
113 }
114 }
115 task() {
116 try {
117 for (let i = 0, requests = this.requests; i < requests.length; i++) {

Callers

nothing calls this directly

Calls 4

questionMethod · 0.95
answerMethod · 0.95
removeMethod · 0.95
readMethod · 0.65

Tested by

no test coverage detected