本网站可以出售:只需60000元直接拥有。QQ:939804642
您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ stasis_message_data函数代码示例

51自学网 2021-06-03 08:22:29
  C++
这篇教程C++ stasis_message_data函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中stasis_message_data函数的典型用法代码示例。如果您正苦于以下问题:C++ stasis_message_data函数的具体用法?C++ stasis_message_data怎么用?C++ stasis_message_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: consumer_exec

static void consumer_exec(void *data, struct stasis_subscription *sub, struct stasis_message *message){    struct consumer *consumer = data;    struct stasis_cache_update *cache_update = stasis_message_data(message);    struct ast_device_state_message *device_state;    if (!cache_update->new_snapshot) {        return;    }    device_state = stasis_message_data(cache_update->new_snapshot);    if (strcmp(device_state->device, UNIT_TEST_DEVICE_IDENTIFIER)) {        /* not a device state we're interested in */        return;    }    {        SCOPED_AO2LOCK(lock, consumer);        ++consumer->event_count;        if (device_state->eid) {            consumer->state = device_state->state;            if (consumer->sig_on_non_aggregate_state) {                consumer->sig_on_non_aggregate_state = 0;                consumer->already_out = 1;                ast_cond_signal(&consumer->out);            }        } else {            consumer->aggregate_state = device_state->state;            consumer->already_out = 1;            ast_cond_signal(&consumer->out);        }    }}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:35,


示例2: sub_endpoint_update_handler

static void sub_endpoint_update_handler(void *data,	struct stasis_subscription *sub,	struct stasis_message *message){	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);	struct stasis_app *app = data;	struct stasis_cache_update *update;	struct ast_endpoint_snapshot *new_snapshot;	struct ast_endpoint_snapshot *old_snapshot;	const struct timeval *tv;	ast_assert(stasis_message_type(message) == stasis_cache_update_type());	update = stasis_message_data(message);	ast_assert(update->type == ast_endpoint_snapshot_type());	new_snapshot = stasis_message_data(update->new_snapshot);	old_snapshot = stasis_message_data(update->old_snapshot);	if (new_snapshot) {		tv = stasis_message_timestamp(update->new_snapshot);		json = simple_endpoint_event("EndpointStateChange", new_snapshot, tv);		if (!json) {			return;		}		app_send(app, json);	}	if (!new_snapshot && old_snapshot) {		unsubscribe(app, "endpoint", old_snapshot->id, 1);	}}
开发者ID:lyx2014,项目名称:Asterisk,代码行数:35,


示例3: confbridge_publish_manager_event

static void confbridge_publish_manager_event(	struct stasis_message *message,	const char *event,	struct ast_str *extra_text){	struct ast_bridge_blob *blob = stasis_message_data(message);	const char *conference_name;	RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);	ast_assert(blob != NULL);	ast_assert(event != NULL);	bridge_text = ast_manager_build_bridge_state_string(blob->bridge);	if (!bridge_text) {		return;	}	conference_name = ast_json_string_get(ast_json_object_get(blob->blob, "conference"));	ast_assert(conference_name != NULL);	if (blob->channel) {		channel_text = ast_manager_build_channel_state_string(blob->channel);	}	manager_event(EVENT_FLAG_CALL, event,		"Conference: %s/r/n"		"%s"		"%s"		"%s",		conference_name,		ast_str_buffer(bridge_text),		S_COR(channel_text, ast_str_buffer(channel_text), ""),		S_COR(extra_text, ast_str_buffer(extra_text), ""));}
开发者ID:huangjingpei,项目名称:asterisk,代码行数:35,


示例4: stasis_message_data

static struct ast_manager_event_blob *system_registry_to_ami(struct stasis_message *message){    struct ast_json_payload *payload = stasis_message_data(message);    const char *channeltype;    const char *username;    const char *domain;    const char *status;    const char *cause;    RAII_VAR(struct ast_str *, cause_string, ast_str_create(32), ast_free);    if (!cause_string) {        return NULL;    }    channeltype = ast_json_string_get(ast_json_object_get(payload->json, "channeltype"));    username = ast_json_string_get(ast_json_object_get(payload->json, "username"));    domain = ast_json_string_get(ast_json_object_get(payload->json, "domain"));    status = ast_json_string_get(ast_json_object_get(payload->json, "status"));    cause = ast_json_string_get(ast_json_object_get(payload->json, "cause"));    if (!ast_strlen_zero(cause)) {        ast_str_set(&cause_string, 0, "Cause: %s/r/n", cause);    }    return ast_manager_event_blob_create(EVENT_FLAG_SYSTEM, "Registry",                                         "ChannelType: %s/r/n"                                         "Username: %s/r/n"                                         "Domain: %s/r/n"                                         "Status: %s/r/n"                                         "%s",                                         channeltype, username, domain, status, ast_str_buffer(cause_string));}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:32,


示例5: cache_update_cb

static void cache_update_cb(void *data, struct stasis_subscription *sub,	struct stasis_message *message){	struct stasis_cache_update *update = stasis_message_data(message);	struct ast_endpoint_snapshot *old_snapshot;	struct ast_endpoint_snapshot *new_snapshot;	if (ast_endpoint_snapshot_type() != update->type) {		return;	}	old_snapshot = stasis_message_data(update->old_snapshot);	new_snapshot = stasis_message_data(update->new_snapshot);	handle_endpoint_update(old_snapshot, new_snapshot);}
开发者ID:MattheusNiels,项目名称:BackupCerberus,代码行数:16,


示例6: parking_event_cb

static void parking_event_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message){	if (stasis_message_type(message) == ast_parked_call_type()) {		struct ast_parked_call_payload *parked_call_message = stasis_message_data(message);		parked_call_message_response(parked_call_message);	}}
开发者ID:lyx2014,项目名称:Asterisk,代码行数:7,


示例7: stasis_message_data

static struct ast_json *dtmf_end_to_json(	struct stasis_message *message,	const struct stasis_message_sanitizer *sanitize){	struct ast_channel_blob *channel_blob = stasis_message_data(message);	struct ast_json *blob = channel_blob->blob;	struct ast_channel_snapshot *snapshot = channel_blob->snapshot;	const char *direction =		ast_json_string_get(ast_json_object_get(blob, "direction"));	const struct timeval *tv = stasis_message_timestamp(message);	struct ast_json *json_channel = ast_channel_snapshot_to_json(snapshot, sanitize);	/* Only present received DTMF end events as JSON */	if (strcasecmp("Received", direction) != 0) {		return NULL;	}	if (!json_channel) {		return NULL;	}	return ast_json_pack("{s: s, s: o, s: O, s: O, s: o}",		"type", "ChannelDtmfReceived",		"timestamp", ast_json_timeval(*tv, NULL),		"digit", ast_json_object_get(blob, "digit"),		"duration_ms", ast_json_object_get(blob, "duration_ms"),		"channel", json_channel);}
开发者ID:jcollie,项目名称:asterisk,代码行数:28,


示例8: channel_enter_cb

static void channel_enter_cb(void *data, struct stasis_subscription *sub,				    struct stasis_message *message){	static const char *swap_name = "SwapUniqueid: ";	struct ast_bridge_blob *blob = stasis_message_data(message);	RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);	const char *swap_id;	bridge_text = ast_manager_build_bridge_state_string(blob->bridge);	channel_text = ast_manager_build_channel_state_string(blob->channel);	if (!bridge_text || !channel_text) {		return;	}	swap_id = ast_json_string_get(ast_json_object_get(blob->blob, "swap"));	manager_event(EVENT_FLAG_CALL, "BridgeEnter",		"%s"		"%s"		"%s%s%s",		ast_str_buffer(bridge_text),		ast_str_buffer(channel_text),		swap_id ? swap_name : "",		S_OR(swap_id, ""),		swap_id ? "/r/n" : "");}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:27,


示例9: stasis_message_data

static struct ast_manager_event_blob *call_pickup_to_ami(struct stasis_message *message){	struct ast_multi_channel_blob *contents = stasis_message_data(message);	struct ast_channel_snapshot *chan;	struct ast_channel_snapshot *target;	struct ast_manager_event_blob *res;	RAII_VAR(struct ast_str *, channel_str, NULL, ast_free);	RAII_VAR(struct ast_str *, target_str, NULL, ast_free);	chan = ast_multi_channel_blob_get_channel(contents, "channel");	target = ast_multi_channel_blob_get_channel(contents, "target");	ast_assert(chan != NULL && target != NULL);	if (!(channel_str = ast_manager_build_channel_state_string(chan))) {		return NULL;	}	if (!(target_str = ast_manager_build_channel_state_string_prefix(target, "Target"))) {		return NULL;	}	res = ast_manager_event_blob_create(EVENT_FLAG_CALL, "Pickup",		"%s"		"%s",		ast_str_buffer(channel_str),		ast_str_buffer(target_str));	return res;}
开发者ID:huangjingpei,项目名称:asterisk,代码行数:31,


示例10: ast_ari_channels_get

void ast_ari_channels_get(struct ast_variable *headers,	struct ast_ari_channels_get_args *args,	struct ast_ari_response *response){	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);	struct stasis_cache *cache;	struct ast_channel_snapshot *snapshot;	cache = ast_channel_cache();	if (!cache) {		ast_ari_response_error(			response, 500, "Internal Server Error",			"Message bus not initialized");		return;	}	msg = stasis_cache_get(cache, ast_channel_snapshot_type(),				   args->channel_id);	if (!msg) {		ast_ari_response_error(			response, 404, "Not Found",			"Channel not found");		return;	}	snapshot = stasis_message_data(msg);	ast_assert(snapshot != NULL);	ast_ari_response_ok(response,				ast_channel_snapshot_to_json(snapshot, NULL));}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:31,


示例11: find_route

static int find_route(	struct stasis_message_router *router,	struct stasis_message *message,	struct stasis_message_route *route_out){	struct stasis_message_route *route = NULL;	struct stasis_message_type *type = stasis_message_type(message);	SCOPED_AO2LOCK(lock, router);	ast_assert(route_out != NULL);	if (type == stasis_cache_update_type()) {		/* Find a cache route */		struct stasis_cache_update *update =			stasis_message_data(message);		route = route_table_find(&router->cache_routes, update->type);	}	if (route == NULL) {		/* Find a regular route */		route = route_table_find(&router->routes, type);	}	if (route == NULL && router->default_route.callback) {		/* Maybe the default route, then? */		route = &router->default_route;	}	if (!route) {		return -1;	}	*route_out = *route;	return 0;}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:35,


示例12: stasis_topic_wait

int stasis_topic_wait(struct stasis_topic *topic){	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);	RAII_VAR(struct stasis_subscription *, sub, NULL, stasis_unsubscribe);	struct caching_guarantee *guarantee;	msg = caching_guarantee_create();	if (!msg) {		return -1;	}	sub = stasis_subscribe(topic, guarantee_handler, msg);	if (!sub) {		return -1;	}	guarantee = stasis_message_data(msg);	ast_mutex_lock(&guarantee->lock);	stasis_publish(topic, msg);	while (!guarantee->done) {		ast_cond_wait(&guarantee->cond, &guarantee->lock);	}	ast_mutex_unlock(&guarantee->lock);	return 0;}
开发者ID:hardikk,项目名称:asterisk,代码行数:26,


示例13: mwi_update_cb

static void mwi_update_cb(void *data, struct stasis_subscription *sub,				    struct stasis_message *message){	struct ast_mwi_state *mwi_state;	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);	if (ast_mwi_state_type() != stasis_message_type(message)) {		return;	}	mwi_state = stasis_message_data(message);	if (!mwi_state) {		return;	}	if (mwi_state->snapshot) {		channel_event_string = ast_manager_build_channel_state_string(mwi_state->snapshot);	}	/*** DOCUMENTATION		<managerEventInstance>			<synopsis>Raised when the state of messages in a voicemail mailbox			has changed or when a channel has finished interacting with a			mailbox.</synopsis>			<syntax>				<channel_snapshot/>				<parameter name="Mailbox">					<para>The mailbox with the new message, specified as <literal>mailbox</literal>@<literal>context</literal></para>				</parameter>				<parameter name="Waiting">					<para>Whether or not the mailbox has messages waiting for it.</para>				</parameter>				<parameter name="New">					<para>The number of new messages.</para>				</parameter>				<parameter name="Old">					<para>The number of old messages.</para>				</parameter>			</syntax>			<description>				<note><para>The Channel related parameters are only present if a				channel was involved in the manipulation of a mailbox. If no				channel is involved, the parameters are not included with the				event.</para>				</note>			</description>		</managerEventInstance>	***/	manager_event(EVENT_FLAG_CALL, "MessageWaiting",			"%s"			"Mailbox: %s/r/n"			"Waiting: %d/r/n"			"New: %d/r/n"			"Old: %d/r/n",			AS_OR(channel_event_string, ""),			mwi_state->uniqueid,			ast_app_has_voicemail(mwi_state->uniqueid, NULL),			mwi_state->new_msgs,			mwi_state->old_msgs);}
开发者ID:asterisk,项目名称:asterisk,代码行数:60,


示例14: RAII_VAR

static struct ast_manager_event_blob *varset_to_ami(struct stasis_message *msg){	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);	struct ast_channel_blob *obj = stasis_message_data(msg);	const char *variable =		ast_json_string_get(ast_json_object_get(obj->blob, "variable"));	const char *value =		ast_json_string_get(ast_json_object_get(obj->blob, "value"));	if (obj->snapshot) {		channel_event_string =			ast_manager_build_channel_state_string(obj->snapshot);	} else {		channel_event_string = ast_str_create(35);		ast_str_set(&channel_event_string, 0,			    "Channel: none/r/n"			    "Uniqueid: none/r/n");	}	if (!channel_event_string) {		return NULL;	}	return ast_manager_event_blob_create(EVENT_FLAG_DIALPLAN, "VarSet",		"%s"		"Variable: %s/r/n"		"Value: %s/r/n",		ast_str_buffer(channel_event_string), variable, value);}
开发者ID:jcollie,项目名称:asterisk,代码行数:29,


示例15: RAII_VAR

struct ast_endpoint_snapshot *ast_endpoint_latest_snapshot(const char *tech,	const char *name){	RAII_VAR(char *, id, NULL, ast_free);	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);	struct ast_endpoint_snapshot *snapshot;	if (ast_strlen_zero(name)) {		ast_asprintf(&id, "%s", tech);	} else {		ast_asprintf(&id, "%s/%s", tech, name);	}	if (!id) {		return NULL;	}	ast_tech_to_upper(id);	msg = stasis_cache_get(ast_endpoint_cache(),		ast_endpoint_snapshot_type(), id);	if (!msg) {		return NULL;	}	snapshot = stasis_message_data(msg);	ast_assert(snapshot != NULL);	ao2_ref(snapshot, +1);	return snapshot;}
开发者ID:alyosha1879,项目名称:asterisk,代码行数:29,


示例16: filter_bridge_type_cb

static int filter_bridge_type_cb(void *obj, void *arg, int flags){	char *bridge_type = arg;	struct ast_bridge_snapshot *snapshot = stasis_message_data(obj);	/* unlink all the snapshots that do not match the bridge type */	return strcmp(bridge_type, snapshot->technology) ? CMP_MATCH : 0;}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:7,


示例17: stasis_message_data

static struct ast_manager_event_blob *contactstatus_to_ami(struct stasis_message *msg){	struct ast_endpoint_blob *obj = stasis_message_data(msg);	RAII_VAR(struct ast_str *, contactstatus_event_string, ast_str_create(64), ast_free);	const char *value;	if (!(value = ast_json_string_get(ast_json_object_get(obj->blob, "uri")))) {		return NULL;	}	ast_str_append(&contactstatus_event_string, 0, "URI: %s/r/n", value);	if (!(value = ast_json_string_get(ast_json_object_get(obj->blob, "contact_status")))) {		return NULL;	}	ast_str_append(&contactstatus_event_string, 0, "ContactStatus: %s/r/n", value);	if (!(value = ast_json_string_get(ast_json_object_get(obj->blob, "aor")))) {		return NULL;	}	ast_str_append(&contactstatus_event_string, 0, "AOR: %s/r/n", value);	if (!(value = ast_json_string_get(ast_json_object_get(obj->blob, "endpoint_name")))) {		return NULL;	}	ast_str_append(&contactstatus_event_string, 0, "EndpointName: %s/r/n", value);	if ((value = ast_json_string_get(ast_json_object_get(obj->blob, "roundtrip_usec")))) {		ast_str_append(&contactstatus_event_string, 0, "RoundtripUsec: %s/r/n", value);	}	return ast_manager_event_blob_create(EVENT_FLAG_SYSTEM, "ContactStatus",		"%s", ast_str_buffer(contactstatus_event_string));}
开发者ID:alyosha1879,项目名称:asterisk,代码行数:33,


示例18: send_bridge_info_item_cb

static int send_bridge_info_item_cb(void *obj, void *arg, void *data, int flags){	char *uniqueid = obj;	struct mansession *s = arg;	char *id_text = data;	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);	struct ast_channel_snapshot *snapshot;	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);	msg = stasis_cache_get(ast_channel_cache(),		ast_channel_snapshot_type(), uniqueid);	if (!msg) {		return 0;	}	snapshot = stasis_message_data(msg);	if (snapshot->tech_properties & AST_CHAN_TP_INTERNAL) {		return 0;	}	channel_text = ast_manager_build_channel_state_string(snapshot);	if (!channel_text) {		return 0;	}	astman_append(s,		"Event: BridgeInfoChannel/r/n"		"%s"		"%s"		"/r/n",		ast_str_buffer(channel_text),		id_text);	return 0;}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:34,


示例19: appcdr_callback

static void appcdr_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message){	struct app_cdr_message_payload *payload;	if (stasis_message_type(message) != appcdr_message_type()) {		return;	}	payload = stasis_message_data(message);	if (!payload) {		return;	}	if (payload->disable) {		if (ast_cdr_set_property(payload->channel_name, AST_CDR_FLAG_DISABLE_ALL)) {			ast_log(AST_LOG_WARNING, "Failed to disable CDRs on channel %s/n",				payload->channel_name);		}	}	if (payload->reenable) {		if (ast_cdr_clear_property(payload->channel_name, AST_CDR_FLAG_DISABLE_ALL)) {			ast_log(AST_LOG_WARNING, "Failed to enable CDRs on channel %s/n",				payload->channel_name);		}	}	if (payload->reset) {		if (ast_cdr_reset(payload->channel_name, payload->keep_variables)) {			ast_log(AST_LOG_WARNING, "Failed to reset CDRs on channel %s/n",				payload->channel_name);		}	}}
开发者ID:huangjingpei,项目名称:asterisk,代码行数:34,


示例20: mwi_app_event_cb

/*! /brief Generic MWI event callback used for one-off events from voicemail modules */static void mwi_app_event_cb(void *data, struct stasis_subscription *sub,				    struct stasis_message *message){	struct ast_mwi_blob *payload = stasis_message_data(message);	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);	RAII_VAR(struct ast_str *, event_buffer, NULL, ast_free);	struct ast_json *event_json = ast_json_object_get(payload->blob, "Event");	if (!event_json) {		return;	}	if (payload->mwi_state && payload->mwi_state->snapshot) {		channel_event_string = ast_manager_build_channel_state_string(payload->mwi_state->snapshot);	}	event_buffer = ast_manager_str_from_json_object(payload->blob, exclude_event_cb);	if (!event_buffer) {		ast_log(AST_LOG_WARNING, "Failed to create payload for event %s/n", ast_json_string_get(event_json));		return;	}	manager_event(EVENT_FLAG_CALL, ast_json_string_get(event_json),			"Mailbox: %s/r/n"			"%s"			"%s",			payload->mwi_state ? payload->mwi_state->uniqueid : "Unknown",			ast_str_buffer(event_buffer),			channel_event_string ? ast_str_buffer(channel_event_string) : "");}
开发者ID:asterisk,项目名称:asterisk,代码行数:31,


示例21: sub_bridge_update_handler

static void sub_bridge_update_handler(void *data,	struct stasis_subscription *sub,	struct stasis_message *message){	struct ast_json *json = NULL;	struct stasis_app *app = data;	struct ast_bridge_snapshot_update *update;	const struct timeval *tv;	update = stasis_message_data(message);	tv = stasis_message_timestamp(message);	if (!update->new_snapshot) {		json = simple_bridge_event("BridgeDestroyed", update->old_snapshot, tv);	} else if (!update->old_snapshot) {		json = simple_bridge_event("BridgeCreated", update->new_snapshot, tv);	} else if (update->new_snapshot && update->old_snapshot		&& strcmp(update->new_snapshot->video_source_id, update->old_snapshot->video_source_id)) {		json = simple_bridge_event("BridgeVideoSourceChanged", update->new_snapshot, tv);		if (json && !ast_strlen_zero(update->old_snapshot->video_source_id)) {			ast_json_object_set(json, "old_video_source_id",				ast_json_string_create(update->old_snapshot->video_source_id));		}	}	if (json) {		app_send(app, json);		ast_json_unref(json);	}	if (!update->new_snapshot && update->old_snapshot) {		unsubscribe(app, "bridge", update->old_snapshot->uniqueid, 1);	}}
开发者ID:roramirez,项目名称:asterisk,代码行数:35,


示例22: bridge_merge_cb

static void bridge_merge_cb(void *data, struct stasis_subscription *sub,				    struct stasis_message *message){	struct ast_bridge_merge_message *merge_msg = stasis_message_data(message);	RAII_VAR(struct ast_str *, to_text, NULL, ast_free);	RAII_VAR(struct ast_str *, from_text, NULL, ast_free);	ast_assert(merge_msg->to != NULL);	ast_assert(merge_msg->from != NULL);	to_text = ast_manager_build_bridge_state_string_prefix(merge_msg->to, "To");	from_text = ast_manager_build_bridge_state_string_prefix(merge_msg->from, "From");	if (!to_text || !from_text) {		return;	}	/*** DOCUMENTATION		<managerEventInstance>			<synopsis>Raised when two bridges are merged.</synopsis>			<syntax>				<bridge_snapshot prefix="To"/>				<bridge_snapshot prefix="From"/>			</syntax>		</managerEventInstance>	***/	manager_event(EVENT_FLAG_CALL, "BridgeMerge",		"%s"		"%s",		ast_str_buffer(to_text),		ast_str_buffer(from_text));}
开发者ID:TheSeanBrady,项目名称:crtc.bcs.versa,代码行数:31,


示例23: caching_topic_exec

static void caching_topic_exec(void *data, struct stasis_subscription *sub,	struct stasis_message *message){	RAII_VAR(struct stasis_caching_topic *, caching_topic_needs_unref, NULL, ao2_cleanup);	struct stasis_caching_topic *caching_topic = data;	const char *id = NULL;	ast_assert(caching_topic != NULL);	ast_assert(caching_topic->topic != NULL);	ast_assert(caching_topic->cache != NULL);	ast_assert(caching_topic->cache->id_fn != NULL);	if (stasis_subscription_final_message(sub, message)) {		caching_topic_needs_unref = caching_topic;	}	/* Handle cache clear event */	if (stasis_cache_clear_type() == stasis_message_type(message)) {		RAII_VAR(struct stasis_message *, old_snapshot, NULL, ao2_cleanup);		RAII_VAR(struct stasis_message *, update, NULL, ao2_cleanup);		struct stasis_message *clear_msg = stasis_message_data(message);		const char *clear_id = caching_topic->cache->id_fn(clear_msg);		struct stasis_message_type *clear_type = stasis_message_type(clear_msg);		ast_assert(clear_type != NULL);		if (clear_id) {			old_snapshot = cache_put(caching_topic->cache, clear_type, clear_id, NULL);			if (old_snapshot) {				update = update_create(old_snapshot, NULL);				stasis_publish(caching_topic->topic, update);				return;			}			ast_log(LOG_ERROR,				"Attempting to remove an item from the %s cache that isn't there: %s %s/n",				stasis_topic_name(caching_topic->topic), stasis_message_type_name(clear_type), clear_id);			return;		}	}	id = caching_topic->cache->id_fn(message);	if (id == NULL) {		/* Object isn't cached; discard */	} else {		/* Update the cache */		RAII_VAR(struct stasis_message *, old_snapshot, NULL, ao2_cleanup);		RAII_VAR(struct stasis_message *, update, NULL, ao2_cleanup);		old_snapshot = cache_put(caching_topic->cache, stasis_message_type(message), id, message);		update = update_create(old_snapshot, message);		if (update == NULL) {			return;		}		stasis_publish(caching_topic->topic, update);	}}
开发者ID:aderbas,项目名称:asterisk,代码行数:59,


示例24: dump_cache_load

static int dump_cache_load(void *obj, void *arg, int flags){	struct stasis_message *msg = obj;	struct ast_endpoint_snapshot *snapshot = stasis_message_data(msg);	handle_endpoint_update(NULL, snapshot);	return 0;}
开发者ID:MattheusNiels,项目名称:BackupCerberus,代码行数:9,


示例25: sub_bridge_update_handler

static void sub_bridge_update_handler(void *data,	struct stasis_subscription *sub,	struct stasis_message *message){	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);	struct stasis_app *app = data;	struct stasis_cache_update *update;	struct ast_bridge_snapshot *new_snapshot;	struct ast_bridge_snapshot *old_snapshot;	const struct timeval *tv;	ast_assert(stasis_message_type(message) == stasis_cache_update_type());	update = stasis_message_data(message);	ast_assert(update->type == ast_bridge_snapshot_type());	new_snapshot = stasis_message_data(update->new_snapshot);	old_snapshot = stasis_message_data(update->old_snapshot);	tv = update->new_snapshot ?		stasis_message_timestamp(update->new_snapshot) :		stasis_message_timestamp(message);	if (!new_snapshot) {		json = simple_bridge_event("BridgeDestroyed", old_snapshot, tv);	} else if (!old_snapshot) {		json = simple_bridge_event("BridgeCreated", new_snapshot, tv);	} else if (new_snapshot && old_snapshot		&& strcmp(new_snapshot->video_source_id, old_snapshot->video_source_id)) {		json = simple_bridge_event("BridgeVideoSourceChanged", new_snapshot, tv);		if (json && !ast_strlen_zero(old_snapshot->video_source_id)) {			ast_json_object_set(json, "old_video_source_id",				ast_json_string_create(old_snapshot->video_source_id));		}	}	if (json) {		app_send(app, json);	}	if (!new_snapshot && old_snapshot) {		unsubscribe(app, "bridge", old_snapshot->uniqueid, 1);	}}
开发者ID:litnimax,项目名称:asterisk,代码行数:44,


示例26: ast_ari_channels_list

void ast_ari_channels_list(struct ast_variable *headers,                           struct ast_ari_channels_list_args *args,                           struct ast_ari_response *response){    RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);    RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);    RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);    struct ao2_iterator i;    void *obj;    struct stasis_message_sanitizer *sanitize = stasis_app_get_sanitizer();    cache = ast_channel_cache();    if (!cache) {        ast_ari_response_error(            response, 500, "Internal Server Error",            "Message bus not initialized");        return;    }    ao2_ref(cache, +1);    snapshots = stasis_cache_dump(cache, ast_channel_snapshot_type());    if (!snapshots) {        ast_ari_response_alloc_failed(response);        return;    }    json = ast_json_array_create();    if (!json) {        ast_ari_response_alloc_failed(response);        return;    }    for (i = ao2_iterator_init(snapshots, 0);            (obj = ao2_iterator_next(&i)); ao2_cleanup(obj)) {        RAII_VAR(struct stasis_message *, msg, obj, ao2_cleanup);        struct ast_channel_snapshot *snapshot = stasis_message_data(msg);        int r;        if (sanitize && sanitize->channel_snapshot                && sanitize->channel_snapshot(snapshot)) {            continue;        }        r = ast_json_array_append(                json, ast_channel_snapshot_to_json(snapshot, NULL));        if (r != 0) {            ast_ari_response_alloc_failed(response);            ao2_cleanup(obj);            ao2_iterator_destroy(&i);            return;        }    }    ao2_iterator_destroy(&i);    ast_ari_response_ok(response, ast_json_ref(json));}
开发者ID:vzar,项目名称:asterisk,代码行数:56,



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


C++ stat函数代码示例
C++ stasis_app_send_command_async函数代码示例
51自学网自学EXCEL、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。
京ICP备13026421号-1