I’m trying to write an RPC callback method that will allow users to refresh their configuration settings. I started using the sum_cb() example, and added both my config read method and a LOG, but it seems that neither of them are called, even though the callback executes and returns the result as expected.
Is there some reason I can’t call other methods from a callback?
static void sum_cb(struct mg_rpc_request_info *ri, void *cb_arg,
struct mg_rpc_frame_info *fi, struct mg_str args)
{
LOG(LL_ERROR, ("===>>>Calling: sum_cb()"));
refreshConfig(&gUserSettings);
double a = 0, b = 0;
if (json_scanf(args.p, args.len, ri->args_fmt, &a, &b) == 2) {
mg_rpc_send_responsef(ri, "%.2lf", a + b);
} else {
mg_rpc_send_errorf(ri, -1, "Bad request. Expected: {\"a\":N1,\"b\":N2}");
}
(void) cb_arg;
(void) fi;
}