示例#1
0
    static int
sca_notify_subscriber_internal( sca_mod *scam, sca_subscription *sub,
	str *headers )
{
    uac_req_t		request;
    dlg_t		*dlg = NULL;
    int			rc = -1;

    dlg = sca_notify_dlg_for_subscription( sub );
    if ( dlg == NULL ) {
	LM_ERR( "Failed to create dlg_t for %s NOTIFY to %.*s",
		sca_event_name_from_type( sub->event ),
		STR_FMT( &sub->subscriber ));
	goto done;
    }

    set_uac_req( &request, (str *)&SCA_METHOD_NOTIFY, headers, NULL, dlg,
			TMCB_LOCAL_COMPLETED, sca_notify_reply_cb, scam );
    rc = scam->tm_api->t_request_within( &request );
    if ( rc < 0 ) {
	LM_ERR( "Failed to send in-dialog %s NOTIFY to %.*s",
		sca_event_name_from_type( sub->event ),
		STR_FMT( &sub->subscriber ));
    }
    /* fall through, return rc from t_request_within */

done:
    if ( dlg != NULL ) {
	pkg_free( dlg );
    }

    return( rc );
}
示例#2
0
static int sca_notify_subscriber_internal(sca_mod *scam, sca_subscription *sub,
		str *headers)
{
	uac_req_t request;
	dlg_t *dlg = NULL;
	str state_str = STR_NULL;
	int rc = -1;

	sca_appearance_state_to_str(sub->state, &state_str);
	LM_DBG("SCA: NOTIFYing subscriber '%.*s' of event '%s' with a state of '%.*s' to index '%d'\n",
			STR_FMT(&sub->subscriber), sca_event_name_from_type(sub->event),
			STR_FMT(&state_str), sub->index);

	dlg = sca_notify_dlg_for_subscription(sub);
	if (dlg == NULL) {
		LM_ERR("Failed to create dlg_t for %s NOTIFY to %.*s\n",
				sca_event_name_from_type(sub->event),
				STR_FMT(&sub->subscriber));
		goto done;
	}

	set_uac_req(&request, (str *)&SCA_METHOD_NOTIFY, headers, NULL, dlg,
			TMCB_LOCAL_COMPLETED, sca_notify_reply_cb, scam);
	rc = scam->tm_api->t_request_within(&request);
	if (rc < 0) {
		LM_ERR("Failed to send in-dialog %s NOTIFY to %.*s\n",
				sca_event_name_from_type(sub->event),
				STR_FMT(&sub->subscriber));
	}
	// fall through, return rc from t_request_within

	done: if (dlg != NULL) {
		if (dlg->route_set != NULL) {
			free_rr(&dlg->route_set);
		}

		pkg_free(dlg);
	}

	return (rc);
}