MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / accept

Method accept

framework/framework/router.ts:24–38  ·  view source on GitHub ↗
(socket: WebSocket, request: IncomingMessage, ctx: KoaContext)

Source from the content-addressed store, hash-verified

22 }
23
24 accept(socket: WebSocket, request: IncomingMessage, ctx: KoaContext) {
25 const match = this.regexp.exec(new URL(request.url, `http://${request.headers.host}`).pathname);
26 if (!match) return false;
27 ctx.params ||= {};
28 for (let i = 0; i < this.keys.length; i++) {
29 ctx.params[this.keys[i].name] = match[i + 1];
30 ctx.HydroContext.args[this.keys[i].name] = match[i + 1];
31 }
32 this.clients.add(socket);
33 socket.on('close', () => {
34 this.clients.delete(socket);
35 });
36 this.callback?.(socket, request, ctx);
37 return true;
38 }
39
40 close() {
41 for (const socket of this.clients) {

Callers 1

constructorMethod · 0.45

Calls 2

addMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected