当前位置: 首页>>代码示例>>C++>>正文


C++ pua_api_t::send_publish方法代码示例

本文整理汇总了C++中pua_api_t::send_publish方法的典型用法代码示例。如果您正苦于以下问题:C++ pua_api_t::send_publish方法的具体用法?C++ pua_api_t::send_publish怎么用?C++ pua_api_t::send_publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pua_api_t的用法示例。


在下文中一共展示了pua_api_t::send_publish方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sca_publish

void sca_publish(b2b_sca_record_t *record, str *extra_hdr)
{
	str_lst_t *new_watcher;
	publ_info_t publ;

	/* TESTING */
	//return;

	memset(&publ, 0, sizeof(publ_info_t));

	publ.id = callinfo_id;
	publ.body = NULL;

	publ.expires = record->expires;

	publ.flag|= UPDATE_TYPE;
	publ.source_flag|= CALLINFO_PUBLISH;
	publ.event|= CALLINFO_EVENT;

	publ.content_type.s = NULL;
	publ.content_type.len = 0;

	publ.etag = NULL;

	publ.extra_headers= extra_hdr;

	publ.outbound_proxy = presence_server;
	publ.cb_param = NULL;

	new_watcher = record->watchers;
	while (new_watcher) {
		publ.pres_uri = &new_watcher->watcher;
		if(pua_api.send_publish(&publ)< 0) {
			LM_ERR("sending publish failed\n");
		}
		new_watcher = new_watcher->next;
	}

	return;
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:40,代码来源:sca_logic.c

示例2: reginfo_event_process

void reginfo_event_process()
{
    	publ_info_t publ;
	subs_info_t subs;
	reginfo_event_t *ev;
	for (;;) {
		LM_DBG("POPPING REGINFO EVENT\n");
	        ev = pop_reginfo_event();
	        LM_DBG("PROCESSING REGINFO EVENT with event [%d]\n", ev->event);

	        switch (ev->event) {
	        case REG_EVENT_PUBLISH:
	        	LM_DBG("Sending out-of-band publish with pres_uri [%.*s] publ_id [%.*s] publ_content_type [%.*s] extra_headers [%.*s]"
				"expires [%d] event [%d]\n",
				ev->pres_uri.len, ev->pres_uri.s, ev->publ_id.len, ev->publ_id.s, ev->publ_content_type.len, ev->publ_content_type.s,
				ev->extra_headers.len, ev->extra_headers.s, ev->expires, ev->reg_info_event);
			LM_DBG("publ_body [%.*s] \n",
				ev->publ_body.len, ev->publ_body.s);
			
			memset(&publ, 0, sizeof(publ_info_t));
			publ.pres_uri = &ev->pres_uri;
			publ.body = &ev->publ_body;
			publ.id = ev->publ_id;
			publ.content_type = ev->publ_content_type;
			publ.expires = ev->expires;

			/* make UPDATE_TYPE, as if this "publish dialog" is not found
			 by pua it will fallback to INSERT_TYPE anyway */
			publ.flag |= ev->flag;
			publ.source_flag |= ev->sourge_flag;
			publ.event |= ev->reg_info_event;
			publ.extra_headers = &ev->extra_headers;

			if (pua.send_publish(&publ) < 0) {
				LM_ERR("Error while sending publish\n");
			}
	        	break;
	        case REG_EVENT_SUBSCRIBE:
	        	memset(&subs, 0, sizeof(subs_info_t));

			subs.remote_target = &ev->subs_remote_target;
			subs.pres_uri= &ev->pres_uri;
			subs.watcher_uri= &ev->subs_watcher_uri;
			subs.expires = ev->expires;

			subs.source_flag= ev->sourge_flag;
			subs.event= ev->reg_info_event;
			subs.contact= &ev->subs_contact;
			subs.extra_headers = &ev->extra_headers;

			if(ev->subs_outbound_proxy.s) {
			    subs.outbound_proxy= &ev->subs_outbound_proxy;
			}

			subs.flag|= ev->flag;
			
			
			LM_DBG("Sending out-of-band subscribe with remote_target [%.*s] pres_uri [%.*s] subs_watcher_uri [%.*s] subs_contact [%.*s] extra_headers [%.*s] "
				"expires [%d] event [%d] flag [%d] source_flag [%d]\n",
				subs.remote_target->len, subs.remote_target->s, subs.pres_uri->len, subs.pres_uri->s, subs.watcher_uri->len, subs.watcher_uri->s,
				subs.contact->len, subs.contact->s, subs.extra_headers->len, subs.extra_headers->s, subs.expires, subs.event, subs.flag, subs.source_flag);
			if(subs.outbound_proxy) {
			    LM_DBG("subs_outbound_proxy [%.*s]\n",
				subs.outbound_proxy->len, subs.outbound_proxy->s);
			}
			

			if(pua.send_subscribe(&subs)< 0) {
				LM_ERR("while sending subscribe\n");
			}
			
	        	break;
	        default:
	        	LM_ERR("Unknown REG event.....ignoring\n");
	        	break;
	        }
	        free_reginfo_event(ev);
	}
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:79,代码来源:async_reginfo.c

示例3: pua_rpc_publish


//.........这里部分代码省略.........
	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;
	}

	dctx = rpc->delayed_ctx_new(c);
	if (dctx == 0) {
		LM_ERR("internal error: failed to create context\n");
		rpc->fault(c, 500, "Internal error: failed to create context");
		return;
	}
	publ.cb_param = dctx;
	publ.source_flag = MI_ASYN_PUBLISH;

	ret = pua_rpc_api.send_publish(&publ);
	LM_DBG("pua send_publish returned %d\n", ret);

	if (dctx->reply_ctx != 0) {
		/* callback was not executed or its execution failed */
		rpc = &dctx->rpc;
		c = dctx->reply_ctx;
	} else {
		return;
	}

	if (ret < 0) {
		LM_ERR("pua send_publish failed\n");
		err_ret = err2reason_phrase(ret, &sip_error, err_buf,
					    sizeof(err_buf), "RPC/PUBLISH") ;
		if (err_ret > 0 ) {
			rpc->fault(c, sip_error, "%s", err_buf);
		} else {
			rpc->fault(c, 500, "RPC/PUBLISH error");
		}
		rpc->delayed_ctx_close(dctx);
	}

	if (ret == 418) {
		rpc->fault(c, 500, "Wrong ETag");
		rpc->delayed_ctx_close(dctx);
	}


	return;
}
开发者ID:krys1976,项目名称:kamailio,代码行数:101,代码来源:pua_rpc.c

示例4: send_partial_publish

int send_partial_publish(ppublic_t *impu, struct pcontact *c, int type)
{
	publ_info_t publ;
	str content_type;
	int id_buf_len;
	char id_buf[512];
	str p_asserted_identity_header;

	content_type.s = "application/reginfo+xml";
	content_type.len = 23;
	
	int len = strlen(P_ASSERTED_IDENTITY_HDR_PREFIX) + pcscf_uri.len + 1 + CRLF_LEN;
	p_asserted_identity_header.s = (char *)pkg_malloc( len );
	if ( p_asserted_identity_header.s == NULL ) {
	    LM_ERR( "insert_asserted_identity: pkg_malloc %d bytes failed", len );
	    goto error;
	}
	
	memcpy(p_asserted_identity_header.s, P_ASSERTED_IDENTITY_HDR_PREFIX, strlen(P_ASSERTED_IDENTITY_HDR_PREFIX));
	p_asserted_identity_header.len = strlen(P_ASSERTED_IDENTITY_HDR_PREFIX);
	memcpy(p_asserted_identity_header.s + p_asserted_identity_header.len, pcscf_uri.s, pcscf_uri.len);
	p_asserted_identity_header.len += pcscf_uri.len;
	*(p_asserted_identity_header.s + p_asserted_identity_header.len) = '>';
	p_asserted_identity_header.len ++;
	memcpy( p_asserted_identity_header.s + p_asserted_identity_header.len, CRLF, CRLF_LEN );
	p_asserted_identity_header.len += CRLF_LEN;
	
	LM_DBG("p_asserted_identity_header: [%.*s]", p_asserted_identity_header.len, p_asserted_identity_header.s);
	
	LM_DBG("Sending publish\n");
	str *body = build_reginfo_partial(impu, c, type);

	if (body == NULL || body->s == NULL) {
		LM_ERR("Error on creating XML-Body for publish\n");
		goto error;
	}
	LM_DBG("XML-Body:\n%.*s\n", body->len, body->s);

	memset(&publ, 0, sizeof(publ_info_t));
	publ.pres_uri = &impu->public_identity;
	publ.body = body;
	id_buf_len = snprintf(id_buf, sizeof(id_buf), "IMSPCSCF_PUBLISH.%.*s", c->aor.len, c->aor.s);
	publ.id.s = id_buf;
	publ.id.len = id_buf_len;
	publ.content_type = content_type;
	publ.expires = 3600;

	/* make UPDATE_TYPE, as if this "publish dialog" is not found
	 by pua it will fallback to INSERT_TYPE anyway */
	publ.flag |= UPDATE_TYPE;
	publ.source_flag |= REGINFO_PUBLISH;
	publ.event |= REGINFO_EVENT;
	publ.extra_headers = &p_asserted_identity_header;

	if (pua.send_publish(&publ) < 0) {
		LM_ERR("Error while sending publish\n");
	}
	if (p_asserted_identity_header.s) {
		pkg_free(p_asserted_identity_header.s);
	}
	
	return 1;

error:
	
	if (p_asserted_identity_header.s) {
		pkg_free(p_asserted_identity_header.s);
	}
	if (body) {
		if (body->s)
			xmlFree(body->s);
		pkg_free(body);
	}
	return -1;
}
开发者ID:AndreyRybkin,项目名称:kamailio,代码行数:75,代码来源:ul_callback.c


注:本文中的pua_api_t::send_publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。