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

Method callback

modules/network/sntp/sntp.js:91–110  ·  view source on GitHub ↗
(message, value)

Source from the content-addressed store, hash-verified

89 super.close();
90 }
91 callback(message, value) {
92 if (Socket.readable !== message)
93 return;
94
95 if (48 !== value)
96 this.failed("unexpected SNTP packet length");
97 else
98 if (4 !== (7 & this.read(Number))) // NTP server mode
99 this.failed("unexpected SNTP packet first byte");
100 else if (0 === this.read(Number)) {
101 this.read(null); // clear unread
102 return; // Kiss-o'-Death - "...KoD packets have no protocol significance and are discarded after inspection"
103 }
104 else {
105 this.read(null, 38);
106 const time = toNumber(this.read(Number), this.read(Number), this.read(Number), this.read(Number));
107 this.close();
108 return this.#callback(SNTP.time, time);
109 }
110 }
111
112 static time = 1;
113 static retry = 2;

Callers

nothing calls this directly

Calls 3

failedMethod · 0.95
closeMethod · 0.95
readMethod · 0.65

Tested by

no test coverage detected