-/*
- * On query "state" from 'jreq' with parameters of 'obj'.
- */
-static void on_state(struct jreq *jreq, struct json_object *obj, void *unused)
-{
- int runid;
- struct json_object *resp;
- if (onrunid(jreq, obj, "state", &runid)) {
- resp = afm_run_state(runid);
- reply(jreq, resp, error_not_found);
- json_object_put(resp);
- }
-}
-
-/*
- * Calls the system daemon to achieve application management of
- * the 'method' gotten from 'jreq' with the parameter's string 'msg'.
- *
- * The principle is very simple: call the corresponding system method
- * and reply its response to the caller.
- *
- * The request and reply is synchronous and is blocking.
- * It is possible to implment it in an asynchrounous way but it
- * would brake the common behaviour. It would be a call like
- * jbus_call_ss(system_bus, method, msg, callback, jreq)
- */
-static void propagate(struct jreq *jreq, const char *msg, const char *method)
-{
- char *reply;
- INFO("method %s propagated with %s", method, msg);
- reply = jbus_call_ss_sync(system_bus, method, msg);
- if (reply) {
- jbus_reply_s(jreq, reply);
- free(reply);
- }
- else
- jbus_reply_error_s(jreq, error_system);
+ INFO("method %s propagated for %s", verb, json_object_to_json_string(obj));
+ if (!pws)
+ jbus_reply_error_s(smsg, "disconnected");
+ else {
+#if defined(AFB_PROTO_WS_VERSION) && (AFB_PROTO_WS_VERSION >= 3)
+ rc = afb_proto_ws_client_call(pws, verb, obj, sessionid, smsg, onbehalf);
+#else
+ rc = afb_proto_ws_client_call(pws, verb, obj, sessionid, smsg);
+#endif
+ if (rc < 0)
+ ERROR("calling %s(%s) failed: %m\n", verb, json_object_to_json_string(obj));
+ }