static apt_bool_t mrcp_client_agent_control_pocess(mrcp_connection_agent_t *agent)
{
	connection_task_msg_data_t task_msg_data;
	apr_size_t size = sizeof(connection_task_msg_data_t);
	apr_status_t status = apr_socket_recv(agent->control_sock, (char*)&task_msg_data, &size);
	if(status == APR_EOF || size == 0) {
		return FALSE;
	}

	switch(task_msg_data.type) {
		case CONNECTION_TASK_MSG_ADD_CHANNEL:
			mrcp_client_agent_channel_add(agent,task_msg_data.channel,task_msg_data.descriptor);
			break;
		case CONNECTION_TASK_MSG_MODIFY_CHANNEL:
			mrcp_client_agent_channel_modify(agent,task_msg_data.channel,task_msg_data.descriptor);
			break;
		case CONNECTION_TASK_MSG_REMOVE_CHANNEL:
			mrcp_client_agent_channel_remove(agent,task_msg_data.channel);
			break;
		case CONNECTION_TASK_MSG_SEND_MESSAGE:
			mrcp_client_agent_messsage_send(agent,task_msg_data.channel,task_msg_data.message);
			break;
		case CONNECTION_TASK_MSG_TERMINATE:
			return FALSE;
	}

	return TRUE;
}
/* Process task message */
static apt_bool_t mrcp_client_agent_msg_process(apt_task_t *task, apt_task_msg_t *task_msg)
{
	apt_poller_task_t *poller_task = apt_task_object_get(task);
	mrcp_connection_agent_t *agent = apt_poller_task_object_get(poller_task);
	connection_task_msg_t *msg = (connection_task_msg_t*) task_msg->data;

	switch(msg->type) {
		case CONNECTION_TASK_MSG_ADD_CHANNEL:
			mrcp_client_agent_channel_add(agent,msg->channel,msg->descriptor);
			break;
		case CONNECTION_TASK_MSG_MODIFY_CHANNEL:
			mrcp_client_agent_channel_modify(agent,msg->channel,msg->descriptor);
			break;
		case CONNECTION_TASK_MSG_REMOVE_CHANNEL:
			mrcp_client_agent_channel_remove(agent,msg->channel);
			break;
		case CONNECTION_TASK_MSG_SEND_MESSAGE:
			mrcp_client_agent_messsage_send(agent,msg->channel,msg->message);
			break;
	}

	return TRUE;
}
static apt_bool_t mrcp_client_agent_control_process(mrcp_connection_agent_t *agent)
{
	apt_bool_t status = TRUE;
	apt_bool_t running = TRUE;
	connection_task_msg_t *msg;

	do {
		apr_thread_mutex_lock(agent->guard);
		msg = apt_cyclic_queue_pop(agent->msg_queue);
		apr_thread_mutex_unlock(agent->guard);
		if(msg) {
			switch(msg->type) {
				case CONNECTION_TASK_MSG_ADD_CHANNEL:
					mrcp_client_agent_channel_add(agent,msg->channel,msg->descriptor);
					break;
				case CONNECTION_TASK_MSG_MODIFY_CHANNEL:
					mrcp_client_agent_channel_modify(agent,msg->channel,msg->descriptor);
					break;
				case CONNECTION_TASK_MSG_REMOVE_CHANNEL:
					mrcp_client_agent_channel_remove(agent,msg->channel);
					break;
				case CONNECTION_TASK_MSG_SEND_MESSAGE:
					mrcp_client_agent_messsage_send(agent,msg->channel,msg->message);
					break;
				case CONNECTION_TASK_MSG_TERMINATE:
					status = FALSE;
					break;
			}
		}
		else {
			running = FALSE;
		}
	}
	while(running == TRUE);
	return status;
}