MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / testConnect

Function testConnect

frontend/src/hooks/useSocketIo.ts:73–91  ·  view source on GitHub ↗
(addr: string, prefix?: string)

Source from the content-addressed store, hash-verified

71 };
72
73 const testConnect = (addr: string, prefix?: string) => {
74 socket = makeSocketIo(addr, prefix);
75
76 return new Promise<Socket<DefaultEventsMap, DefaultEventsMap>>((resolve, reject) => {
77 if (!socket) return reject(new Error("[Socket.io] socket is undefined"));
78
79 socket.on("connect", () => {
80 try {
81 socket?.disconnect();
82 } finally {
83 resolve(socket!);
84 }
85 });
86
87 socket.on("connect_error", (error) => {
88 reject(error);
89 });
90 });
91 };
92
93 return { testConnect, testFrontendSocket, socketStatus };
94}

Callers 1

testFrontendSocketFunction · 0.85

Calls 3

makeSocketIoFunction · 0.85
onMethod · 0.80
disconnectMethod · 0.80

Tested by

no test coverage detected