MCPcopy Create free account
hub / github.com/TanStack/devtools / connectWebSocket

Method connectWebSocket

packages/event-bus/src/client/client.ts:232–256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230 }
231
232 private connectWebSocket() {
233 this.debugLog('Connecting to WebSocket server')
234
235 const wsProtocol = this.#protocol === 'https' ? 'wss' : 'ws'
236 this.#socket = new WebSocket(
237 `${wsProtocol}://${this.#host}:${this.#port}/__devtools/ws`,
238 )
239 this.#socket.onopen = () => {
240 this.debugLog('WebSocket connection opened')
241 this.flushPendingServerEvents()
242 }
243 this.#socket.onmessage = (e) => {
244 this.debugLog('Received message from server', e.data)
245 this.handleEventReceived(e.data)
246 }
247 this.#socket.onclose = () => {
248 this.debugLog('WebSocket connection closed')
249 this.#socket = null
250 // Drop any still-queued events — there is no open socket to deliver them.
251 this.#pendingServerEvents = []
252 }
253 this.#socket.onerror = () => {
254 this.debugLog('WebSocket connection error')
255 }
256 }
257
258 private connect() {
259 try {

Callers 1

connectMethod · 0.95

Calls 3

debugLogMethod · 0.95
handleEventReceivedMethod · 0.95

Tested by

no test coverage detected