MCPcopy Create free account
hub / github.com/gnmyt/Nexterm / handler

Method handler

server/lib/ScriptLayer.js:128–141  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

126
127 createMessageHandler(ws) {
128 const handler = (msg) => {
129 const str = msg.toString();
130 if (!str.startsWith(SCRIPT_MAGIC)) return;
131 try {
132 const data = JSON.parse(str.slice(1));
133 if (data.type === MSG.INPUT_RESPONSE && this.pending) {
134 this.stream.write((data.value || this.pending.default || "") + "\n");
135 this.pending = null;
136 } else if (data.type === MSG.INPUT_CANCELLED) {
137 this.stream.write("\x03");
138 this.pending = null;
139 }
140 } catch (e) {}
141 };
142 ws.on("message", handler);
143 this.handlers.add({ ws, handler });
144 this.replayEvents(ws);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected