| 3502 | auto payload = callContext.getParameter(0); |
| 3503 | |
| 3504 | auto callback = callContext.getParameterAsFunction(1); |
| 3505 | if (!callContext.getExceptionTracker()) { |
| 3506 | return Value::undefined(); |
| 3507 | } |
| 3508 | |
| 3509 | daemonClient->submitRequest(payload, callback); |
| 3510 | |
| 3511 | return Value::undefined(); |
| 3512 | }))); |
| 3513 | |
| 3514 | static auto kDaemonClientKey = STRING_LITERAL("DaemonClient"); |
| 3515 | |
| 3516 | auto daemonClientJs = valueToJSValue(jsEntry.jsContext, |
| 3517 | wrappedDaemonClient, |
| 3518 | ReferenceInfoBuilder().withObject(kDaemonClientKey), |
| 3519 | jsEntry.exceptionTracker); |
| 3520 | if (!jsEntry.exceptionTracker) { |
| 3521 | onRecoverableError("daemonClientConnected", jsEntry.exceptionTracker); |
| 3522 | return; |
| 3523 | } |
| 3524 | |
| 3525 | _daemonClients[daemonClient->getConnectionId()] = |
| 3526 | JSValueRef::makeRetained(jsEntry.jsContext, daemonClientJs.get()); |
| 3527 | |
| 3528 | auto jsDebuggerInfo = jsEntry.jsContext.getDebuggerInfo(); |
| 3529 | if (jsDebuggerInfo.has_value()) { |
| 3530 | daemonClient->sendJsDebuggerInfo(jsDebuggerInfo.value().debuggerPort, |
| 3531 | jsDebuggerInfo.value().websocketTargets); |
| 3532 | } |
| 3533 | |
| 3534 | notifyDaemonClientEvent(DaemonClientEventTypeConnected, daemonClientJs.get(), JSValue(), jsEntry); |
| 3535 | if (!jsEntry.exceptionTracker) { |
| 3536 | onRecoverableError("daemonClientConnected", jsEntry.exceptionTracker); |
| 3537 | return; |
| 3538 | } |
| 3539 | }); |
| 3540 | } |
| 3541 | |
| 3542 | void JavaScriptRuntime::daemonClientDisconnected(const Shared<IDaemonClient>& daemonClient) { |
| 3543 | dispatchOnJsThreadUnattributed([=](JavaScriptEntryParameters& jsEntry) { |
| 3544 | const auto& it = _daemonClients.find(daemonClient->getConnectionId()); |
| 3545 | if (it != _daemonClients.end()) { |
| 3546 | auto daemonClientJs = it->second; |
| 3547 | _daemonClients.erase(it); |
| 3548 | |
| 3549 | notifyDaemonClientEvent(DaemonClientEventTypeDisconnected, daemonClientJs.get(), JSValue(), jsEntry); |
| 3550 | if (!jsEntry.exceptionTracker) { |
| 3551 | onRecoverableError("daemonClientDisconnected", jsEntry.exceptionTracker); |
| 3552 | return; |
| 3553 | } |
| 3554 | } |
| 3555 | }); |
| 3556 | } |
| 3557 | |
| 3558 | void JavaScriptRuntime::daemonClientDidReceiveClientPayload(const Shared<IDaemonClient>& daemonClient, |
| 3559 | int senderClientId, |
| 3560 | const BytesView& payload) { |
| 3561 | dispatchOnJsThreadUnattributed([=](JavaScriptEntryParameters& entry) { |
nothing calls this directly
no test coverage detected