Daniel-Constantin Mierla writes:
Check rpc_t_uac_wait() implementation in tm/rpc_uac.c -- it seems to be what you are looking for as an example.
beats me. far too complex stuff without any documentation.
-- juha
void rpc_publish(rpc_t* rpc, void* c) { str pres_uri, expires, event, content_type, id, etag, outbound_proxy, extra_headers, body; rpc_delayed_ctx_t* dctx; int exp, sign, ret, err_ret;
body.s = 0; body.len = 0; dctx = 0;
LM_DBG("rpc_publish ...\n");
if ((rpc->capabilities == 0) || !(rpc->capabilities(c) & RPC_DELAYED_REPLY)) { rpc->fault(c, 600, "Reply wait/async mode not supported" " by this rpc transport"); return; }
ret = rpc->scan(c, "SSSSSSSS*S", &pres_uri, &expires, &event, &content_type, &id, &etag, outbound_proxy, &extra_headers, &body); if (ret < 8 && !(-ret == 8)){ rpc->fault(c, 400, "too few parameters (%d/5)", ret?ret:-ret); return; }
if (parse_uri(pres_uri.s, pres_uri.len, &uri) <0) { LM_ERR("bad resentity uri\n"); rpc->fault(c, 400, "Invalid presentity uri '%s'", pres_ruri.s); return; } LM_DBG("presentity uri '%.*s'\n", pres_uri.len, pres_uri.s);
if (expires.s[0]== '-') { sign= -1; expires.s++; expires.len--; } else { sign = 1; } if (str2int(&expires, (unsigned int*)&exp) < 0) { LM_ERR("invalid expires parameter\n" ); rpc->fault(c, 400, "Invalid expires '%s'", expires.s); return; } exp= exp * sign; LM_DBG("expires '%d'\n", exp);
LM_DBG("event '%.*s'\n", event.len, event.s);
LM_DBG("content type '%.*s'\n", content_type.len, content_type.s);
LM_DBG("id '%.*s'\n", id.len, id.s);
LM_DBG("ETag '%.*s'\n", etag.len, etag.s);
LM_DBG("outbound_proxy '%.*s'\n", outbound_proxy.len, outbound_proxy.s);
LM_DBG("extra headers '%.*s'\n", extra_headers.len, extra_headers.s);
if (body.len > 0) LM_DBG("body '%.*s'\n", body.len, body.s);
if ((body.s == 0) && (content_type.len != 1 || content_type.s[0] != '.')) { LM_ERR("body is missing, but content type is not .\n"); rpc->fault(c, 400, "Body is missing"); return; }
memset(&publ, 0, sizeof(publ_info_t)); publ.pres_uri= &pres_uri;
publ.expires= exp;
publ.event= get_event_flag(&event); if (publ.event < 0) { LM_ERR("unknown event '%.*s'\n", event.len, event.s); rpc->fault(c, 400, "Unknown event"); return; }
if (content_type.len != 1) { publ.content_type= content_type; }
if (!((id.len == 1) && (id.s[0]== '.'))) { publ.id= id; }
if (!((etag.len== 1) && (etag.s[0]== '.'))) { publ.etag= &etag; }
if (!((outbound_proxy.len == 1) && (outbound_proxy.s[0] == '.'))) { publ.outbound_proxy = &outbound_proxy; }
if (!((extra_headers.len == 1) && (extra_headers.s[0] == '.'))) { publ.extra_headers = &extra_headers; }
if (body.s != 0) { publ.body= &body; }
LM_DBG("send publish\n");
/* do some magic to call pua_send_publish(&publ) asynchronously */
}