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

Method constructor

examples/io/udp/sntp/sntp.js:22–43  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

20 #onError;
21 #timer;
22 constructor(options) {
23 this.#udp = new UDP({
24 target: this,
25 onReadable: this.#onReadable
26 });
27
28 this.#onTime = options.onTime;
29 if (!this.#onTime)
30 throw new Error("onTime required");
31
32 this.#onError = options.onError;
33
34 System.resolve(options.host, (name, address) => {
35 if (!address) {
36 this.#onError?.();
37 return;
38 }
39
40 request.call(this.#udp, address);
41 this.#timer = System.setInterval(() => request.call(this.#udp, address), 5 * 1000);
42 });
43 }
44 close() {
45 if (this.#timer)
46 System.clearInterval(this.#timer);

Callers

nothing calls this directly

Calls 3

setIntervalMethod · 0.80
resolveMethod · 0.45
#onErrorMethod · 0.45

Tested by

no test coverage detected