MCPcopy Create free account
hub / github.com/Snapchat/Valdi / processEvent

Method processEvent

valdi/src/valdi/runtime/Debugger/DaemonClient.cpp:124–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void 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
156Shared<DaemonClientDataSender> DaemonClient::getDataSender() const {
157 std::lock_guard<Mutex> lock(_mutex);

Callers

nothing calls this directly

Calls 9

getDataBytesForKeyFunction · 0.85
ResourceIdClass · 0.85
getMapValueMethod · 0.80
isNullOrUndefinedMethod · 0.45
getArrayMethod · 0.45
toStringBoxMethod · 0.45
toIntMethod · 0.45

Tested by

no test coverage detected