MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / connectHandle

Method connectHandle

packages/message/server.ts:173–194  ·  view source on GitHub ↗
(msg: string, params: any, con: MessageConnect)

Source from the content-addressed store, hash-verified

171 }
172
173 private connectHandle(msg: string, params: any, con: MessageConnect) {
174 const func = this.apiFunctionMap.get(msg);
175 if (func) {
176 const ret = func(params, new SenderConnect(con));
177 if (ret) {
178 if (ret instanceof Promise) {
179 ret
180 .then((data) => {
181 data && con.sendMessage({ code: 0, data });
182 })
183 .catch((e: Error) => {
184 con.sendMessage({ code: -1, message: formatErrorToClient(e) });
185 this.logger.error("connectHandle error", Logger.E(e));
186 });
187 return true;
188 } else {
189 con.sendMessage({ code: 0, data: ret });
190 }
191 }
192 return true;
193 }
194 }
195
196 private messageHandle(
197 action: string,

Callers 2

constructorMethod · 0.95
server.test.tsFile · 0.80

Calls 6

funcFunction · 0.85
formatErrorToClientFunction · 0.85
errorMethod · 0.80
EMethod · 0.80
getMethod · 0.65
sendMessageMethod · 0.65

Tested by

no test coverage detected