MCPcopy Create free account
hub / github.com/3rdparty/libprocess / Object

Method Object

include/process/event.hpp:258–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256
257
258inline Event::operator JSON::Object() const
259{
260 JSON::Object object;
261
262 struct Visitor : EventVisitor
263 {
264 explicit Visitor(JSON::Object* _object) : object(_object) {}
265
266 void visit(const MessageEvent& event) override
267 {
268 object->values["type"] = "MESSAGE";
269
270 const Message& message = event.message;
271
272 object->values["name"] = message.name;
273 object->values["from"] = stringify(message.from);
274 object->values["to"] = stringify(message.to);
275 object->values["body"] = message.body;
276 }
277
278 void visit(const HttpEvent& event) override
279 {
280 object->values["type"] = "HTTP";
281
282 const http::Request& request = *event.request;
283
284 object->values["method"] = request.method;
285 object->values["url"] = stringify(request.url);
286 }
287
288 void visit(const DispatchEvent& event) override
289 {
290 object->values["type"] = "DISPATCH";
291 }
292
293 void visit(const ExitedEvent& event) override
294 {
295 object->values["type"] = "EXITED";
296 }
297
298 void visit(const TerminateEvent& event) override
299 {
300 object->values["type"] = "TERMINATE";
301 }
302
303 JSON::Object* object;
304 } visitor(&object);
305
306 visit(&visitor);
307
308 return object;
309}
310
311} // namespace process {
312

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected