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

Method add

modules/io/dnssd/dnssd.js:111–126  ·  view source on GitHub ↗
(service)

Source from the content-addressed store, hash-verified

109 delete claim.initial;
110 }
111 add(service) {
112 this.services.push(service);
113
114 this.write(this.reply(null, 0x1F | 0x8000, service, true)); // remove before adding to clear stale state in clients
115 service.timer = Timer.repeat(timer => {
116 this.write(this.reply(null, 0x1F, service));
117 timer.interval *= 2;
118 if (timer.interval > 16000) {
119 Timer.clear(timer);
120 delete service.timer;
121 }
122 else
123 Timer.schedule(timer, timer.interval, timer.interval);
124 }, 500);
125 service.timer.interval = 500;
126 }
127 update(service) {
128 const index = this.services.indexOf(service);
129 if (index < 0) throw new Error("service not found");

Callers

nothing calls this directly

Calls 6

writeMethod · 0.95
replyMethod · 0.95
repeatMethod · 0.80
scheduleMethod · 0.80
pushMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected