MCPcopy
hub / github.com/coder/mux / closeWebSocket

Function closeWebSocket

src/node/services/browser/BrowserBridgeServer.ts:44–57  ·  view source on GitHub ↗
(ws: WebSocket, code?: number, reason?: string)

Source from the content-addressed store, hash-verified

42}
43
44function closeWebSocket(ws: WebSocket, code?: number, reason?: string): void {
45 try {
46 if (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING) {
47 ws.close(code, reason);
48 return;
49 }
50
51 if (ws.readyState !== WebSocket.CLOSED) {
52 ws.terminate();
53 }
54 } catch (error) {
55 log.debug("BrowserBridgeServer: WebSocket close failed", { code, reason, error });
56 }
57}
58
59function rejectUpgrade(socket: Duplex): void {
60 try {

Callers 5

onErrorFunction · 0.70
handleUpgradeMethod · 0.70
stopMethod · 0.70
cleanupPairMethod · 0.70

Calls 3

debugMethod · 0.80
closeMethod · 0.65
terminateMethod · 0.65

Tested by

no test coverage detected