(
req: IncomingMessage,
socket: Duplex,
head: Buffer,
isPing: boolean,
)
| 198 | return true |
| 199 | } |
| 200 | const handleUpgrade = ( |
| 201 | req: IncomingMessage, |
| 202 | socket: Duplex, |
| 203 | head: Buffer, |
| 204 | isPing: boolean, |
| 205 | ) => { |
| 206 | wss.handleUpgrade(req, socket as Socket, head, (ws) => { |
| 207 | // vite-ping is allowed to connect from anywhere |
| 208 | // we close the connection immediately without connection event |
| 209 | // so that the client does not get included in `wss.clients` |
| 210 | if (isPing) { |
| 211 | ws.close(/* Normal Closure */ 1000) |
| 212 | return |
| 213 | } |
| 214 | wss.emit('connection', ws, req) |
| 215 | }) |
| 216 | } |
| 217 | const wss: WebSocketServerRaw_ = new WebSocketServerRaw({ noServer: true }) |
| 218 | wss.shouldHandle = shouldHandle |
| 219 |
no test coverage detected