MCPcopy
hub / github.com/vitejs/vite / emitCustomEvent

Function emitCustomEvent

packages/vite/src/node/server/ws.ts:287–299  ·  view source on GitHub ↗
(
    event: T,
    data: InferCustomEventPayload<T>,
    socket: WebSocketRaw,
  )

Source from the content-addressed store, hash-verified

285 }
286
287 const emitCustomEvent = <T extends string>(
288 event: T,
289 data: InferCustomEventPayload<T>,
290 socket: WebSocketRaw,
291 ) => {
292 const listeners = customListeners.get(event)
293 if (!listeners?.size) return
294
295 const client = getSocketClient(socket)
296 for (const listener of listeners) {
297 listener(data, client)
298 }
299 }
300
301 wss.on('connection', (socket) => {
302 socket.on('message', (raw) => {

Callers 1

createWebSocketServerFunction · 0.85

Calls 3

getSocketClientFunction · 0.85
listenerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected