MCPcopy Index your code
hub / github.com/plotly/dash / connect

Method connect

dash/dash-renderer/src/utils/workerClient.ts:92–132  ·  view source on GitHub ↗

* Initialize the worker connection. * @param workerUrl URL to the SharedWorker script * @param serverUrl WebSocket server URL * @param inactivityTimeout Optional inactivity timeout in ms * @param heartbeatInterval Optional heartbeat interval in ms

(
        workerUrl: string,
        serverUrl: string,
        inactivityTimeout?: number,
        heartbeatInterval?: number
    )

Source from the content-addressed store, hash-verified

90 * @param heartbeatInterval Optional heartbeat interval in ms
91 */
92 public async connect(
93 workerUrl: string,
94 serverUrl: string,
95 inactivityTimeout?: number,
96 heartbeatInterval?: number
97 ): Promise<void> {
98 if (this.worker) {
99 // Already connected
100 return;
101 }
102
103 // Create the SharedWorker
104 this.worker = new SharedWorker(workerUrl, {
105 name: 'dash-ws-worker'
106 });
107
108 // Set up message handling
109 this.worker.port.onmessage = this.handleMessage.bind(this);
110
111 // Create promise for connection
112 this.connectionPromise = new Promise(resolve => {
113 this.connectionResolve = resolve;
114 });
115
116 // Start the port
117 this.worker.port.start();
118
119 // Send connect message
120 this.worker.port.postMessage({
121 type: WorkerMessageType.CONNECT,
122 rendererId: this.rendererId,
123 payload: {
124 serverUrl,
125 inactivityTimeout,
126 heartbeatInterval
127 }
128 });
129
130 // Wait for connection
131 await this.connectionPromise;
132 }
133
134 /**
135 * Disconnect from the worker.

Callers 2

ensureConnectedMethod · 0.95
initializeWebSocketFunction · 0.45

Calls 1

startMethod · 0.45

Tested by

no test coverage detected