(config, state)
| 320 | } |
| 321 | |
| 322 | async function pollRpc(config, state) { |
| 323 | const response = await studioJson( |
| 324 | config, |
| 325 | "/api/actions/provider-hosts/rpc/next", |
| 326 | { |
| 327 | hostId: config.hostId, |
| 328 | hostToken: config.hostToken, |
| 329 | }, |
| 330 | ); |
| 331 | if (!response?.request) { |
| 332 | return; |
| 333 | } |
| 334 | const task = handleRpc(config, response.request).catch((error) => { |
| 335 | console.error( |
| 336 | `[simdeck-provider] rpc ${response.request.id} failed: ${describeError(error)}`, |
| 337 | ); |
| 338 | }); |
| 339 | state.activeRequests.add(task); |
| 340 | task.finally(() => state.activeRequests.delete(task)); |
| 341 | } |
| 342 | |
| 343 | async function handleRpc(config, request) { |
| 344 | if (isWebSocketUpgradeRequest(request)) { |
no test coverage detected