Exemple #1
0
/**
 * \brief This function is callback function for receiving of command Node_Link.
 *
 * It means, that this function is called, when verse_callback_update
 * is executed and there is any Node_Link command in incoming queue.
 *
 * \param[in]	session_id		The ID of session with some verse server
 * \param[in]	parent_node_id	The ID of new parent node
 * \param[in]	child_node_id	The ID of child node
 */
static void cb_receive_node_link(const uint8_t session_id,
		const uint32_t parent_node_id,
		const uint32_t child_node_id)
{
	printf("%s() session_id: %d, parent_node_id: %d, child_node_id: %d\n",
			__FUNCTION__, session_id, parent_node_id, child_node_id);

	if(parent_node_id == VRS_SCENE_PARENT_NODE_ID && child_node_id == my_test_node_id) {

		/* Test of creating new Tag Group in my own node */
		vrs_send_taggroup_create(session_id, my_test_node_prio, child_node_id, MY_TEST_TAGGROUP_CT);

		/* Test of creating new Layer in my own node */
		vrs_send_layer_create(session_id, my_test_node_prio, my_test_node_id, 0xFFFF, VRS_VALUE_TYPE_REAL64, 4, MY_TEST_LAYER_CT);
	}
}
static void cb_receive_node_create(const uint8 session_id,
		const uint32 node_id,
		const uint32 parent_id,
		const uint16 user_id,
		const uint16 custom_type)
{
	struct ParticleSenderNode *sender_node;
	struct Particle_Sender *sender;

#if NO_DEBUG_PRINT != 1
	printf("%s() session_id: %d, node_id: %d, parent_id: %d, user_id: %d, custom_type: %d\n",
			__FUNCTION__, session_id, node_id, parent_id, user_id, custom_type);
#endif

	if(user_id != ctx->verse.user_id) {
		return;
	}

	if(parent_id == ctx->verse.avatar_id) {
		switch(custom_type) {
		case PARTICLE_SCENE_NODE:
			if(ctx->verse.particle_scene_node == NULL) {
				/* Create node of particle scene */
				ctx->verse.particle_scene_node = create_particle_scene_node(node_id);

				/* Add node to lookup table*/
				lu_add_item(ctx->verse.lu_table, node_id, ctx->verse.particle_scene_node);

				vrs_send_node_link(session_id, VRS_DEFAULT_PRIORITY, VRS_SCENE_PARENT_NODE_ID, node_id);
				vrs_send_node_subscribe(session_id, VRS_DEFAULT_PRIORITY, node_id, 0, 0);
				vrs_send_taggroup_create(session_id, VRS_DEFAULT_PRIORITY, node_id, PARTICLE_SCENE_TG);
			}
			break;
		case PARTICLE_SENDER_NODE:
			if(v_list_count_items(&ctx->verse.particle_scene_node->senders) < (int32)ctx->sender_count) {
				sender_node = create_particle_sender_node(ctx->verse.particle_scene_node, node_id);

				/* Find unassigned sender */
				sender = ctx->senders.first;
				while(sender != NULL) {
					if(sender->sender_node == NULL) {
						break;
					}
					sender = sender->next;
				}

				/* Create reference */
				if(sender != NULL) {
					sender->sender_node = sender_node;
					sender_node->sender = sender;
				}

				/* Is it sender node created by this client */
				if(parent_id == ctx->verse.avatar_id) {
					ctx->sender = sender;
				}

				/* Add node to lookup table*/
				lu_add_item(ctx->verse.lu_table, node_id, sender_node);

				v_list_add_tail(&ctx->verse.particle_scene_node->senders, sender_node);

				vrs_send_node_subscribe(session_id, VRS_DEFAULT_PRIORITY,
						node_id, 0, 0);
				vrs_send_node_link(session_id, VRS_DEFAULT_PRIORITY,
						ctx->verse.particle_scene_node->node_id, node_id);
				vrs_send_taggroup_create(session_id, VRS_DEFAULT_PRIORITY,
						node_id, PARTICLE_SENDER_TG);
				vrs_send_layer_create(session_id, VRS_DEFAULT_PRIORITY,
						node_id, 0xFFFF, VRS_VALUE_TYPE_REAL32, 3, PARTICLE_POS_LAYER);
			}
			break;
		}
	}
}
Exemple #3
0
static void cb_receive_layer_create(const uint8_t session_id,
		const uint32_t node_id,
		const uint16_t parent_layer_id,
		const uint16_t layer_id,
		const uint8_t data_type,
		const uint8_t count,
		const uint16_t custom_type)
{
	printf("%s(): session_id: %u, node_id: %u, parent_layer_id: %d, layer_id: %d, data_type: %d, count: %d, custom_type: %d\n",
			__FUNCTION__, session_id, node_id, parent_layer_id, layer_id, data_type, count, custom_type);

	if(node_id == my_test_node_id && custom_type == MY_TEST_LAYER_CT) {
		uint8_t uint8_t_val[4] = {123, 124, 125, 126};
		uint16_t uint16_t_val[4] = {1234, 456, 7890, 4321};
		uint32_t uint32_t_val[4] = {12345, 67890, 98765, 43210};
		uint64_t uint64_t_val[4] = {123456, 789012, 345678, 9012345};
		float real16_t_val[4] = {123.45, 678.90, -123.45, -678.90};
		float real32_t_val[4] = {1234.567, -8901.234, 5678.901, -2345.678};
		double real64_t_val[4] = {-1234567.890, 0.1234, 100000.9999, -0.000001234};
		void *value;

		my_test_layer_id = layer_id;

		/* Test of subscribing to layer */
		vrs_send_layer_subscribe(session_id, my_test_node_prio, node_id, layer_id, 0, 0);

		/* Test of creating child layer */
		vrs_send_layer_create(session_id, my_test_node_prio,
				node_id, layer_id, VRS_VALUE_TYPE_REAL32, 2, MY_TEST_CHILD_LAYER_CT);

		/* Test sending some values of tag types */
		switch(data_type) {
		case VRS_VALUE_TYPE_UINT8:
			value = uint8_t_val;
			break;
		case VRS_VALUE_TYPE_UINT16:
			value = uint16_t_val;
			break;
		case VRS_VALUE_TYPE_UINT32:
			value = uint32_t_val;
			break;
		case VRS_VALUE_TYPE_UINT64:
			value = uint64_t_val;
			break;
		case VRS_VALUE_TYPE_REAL16:
			/* TODO: convert float values to half-float values */
			value = real16_t_val;
			break;
		case VRS_VALUE_TYPE_REAL32:
			value = real32_t_val;
			break;
		case VRS_VALUE_TYPE_REAL64:
			value = real64_t_val;
			break;
		default:
			value = NULL;
			break;
		}

		/* Test of sending set value */
		vrs_send_layer_set_value(session_id, my_test_node_prio,
				node_id, layer_id, 10, data_type, count, value);

	}

	if(node_id == my_test_node_id &&
			parent_layer_id == my_test_layer_id &&
			custom_type == MY_TEST_CHILD_LAYER_CT) {
		/* Test of destroying parent layer */
		vrs_send_layer_destroy(session_id, my_test_node_prio, node_id, parent_layer_id);
	}
}