MCPcopy
hub / github.com/cpaczek/skylight / onMessage

Method onMessage

tracker/src/upstream.ts:103–121  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

101 }
102
103 private onMessage(raw: string): void {
104 let msg: ServerMessage;
105 try {
106 msg = JSON.parse(raw) as ServerMessage;
107 } catch {
108 return;
109 }
110 if (msg.type === "config") {
111 this.config = mergeConfig(DEFAULT_CONFIG, msg.config);
112 this.events.onConfig?.(this.config);
113 } else if (msg.type === "aircraft") {
114 this.aircraft.clear();
115 for (const ac of msg.aircraft) {
116 if (ac.ts == null) ac.ts = msg.now;
117 this.aircraft.set(ac.hex, ac);
118 }
119 this.events.onSnapshot?.(msg.now, msg.aircraft);
120 }
121 }
122}
123
124/**

Callers 1

openMethod · 0.95

Calls 4

mergeConfigFunction · 0.85
onConfigMethod · 0.80
setMethod · 0.80
onSnapshotMethod · 0.80

Tested by

no test coverage detected