| 122 | } |
| 123 | |
| 124 | void DaemonClient::processEvent(const Value& event) { |
| 125 | auto updatedResources = event.getMapValue("updated_resources"); |
| 126 | if (!updatedResources.isNullOrUndefined()) { |
| 127 | auto resources = Valdi::makeShared<std::vector<Shared<Resource>>>(); |
| 128 | for (const auto& resource : *updatedResources.getMapValue("resources").getArray()) { |
| 129 | auto bundleName = resource.getMapValue("bundle_name").toStringBox(); |
| 130 | auto path = resource.getMapValue("file_path_within_bundle").toStringBox(); |
| 131 | |
| 132 | auto dataBytesView = getDataBytesForKey(resource, "data_string", "data_base64"); |
| 133 | |
| 134 | auto outResource = |
| 135 | Valdi::makeShared<Resource>(ResourceId(std::move(bundleName), std::move(path)), dataBytesView); |
| 136 | resources->emplace_back(std::move(outResource)); |
| 137 | } |
| 138 | |
| 139 | _listener->didReceiveUpdatedResources(resources); |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | auto payloadFromClient = event.getMapValue("payload_from_client"); |
| 144 | if (!payloadFromClient.isNullOrUndefined()) { |
| 145 | auto dataBytesView = getDataBytesForKey(payloadFromClient, "payload_string", "payload_base64"); |
| 146 | |
| 147 | _listener->didReceiveClientPayload( |
| 148 | this, payloadFromClient.getMapValue("sender_client_id").toInt(), dataBytesView); |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | // If we make it this far, something has gone wrong. |
| 153 | VALDI_ERROR(*_logger, "Invalid daemon client payload, event not set"); |
| 154 | } |
| 155 | |
| 156 | Shared<DaemonClientDataSender> DaemonClient::getDataSender() const { |
| 157 | std::lock_guard<Mutex> lock(_mutex); |
nothing calls this directly
no test coverage detected