示例#1
0
文件: exec.c 项目: hanguangyi/egui
si_t application_event_handler(struct egui_uds* uds_ptr, addr_t arg)
{
	union message msg;

	if(0 != comm_recv_msg(uds_ptr, &msg))
	{
		EGUI_PRINT_ERROR("failed to recv msg");
		return SELECTER_RETURN_TYPE_CONTINUE;
	}

	application_handle_message(&msg);

	/**
	 * 处理器消息过程中,应用程序需要发送一些请求,等待回应的过程中,窗口管理器可能会发送消息。
	 * 因此当请求处理完毕之后,再逐一处理消息。
	 **/
	while(!queue_empty(&global_application.message_queue))
	{
		union message* msg = queue_front(&global_application.message_queue);
		application_handle_message(msg);
		queue_pop(&global_application.message_queue);
	}

	return SELECTER_RETURN_TYPE_CONTINUE;
}
示例#2
0
/**
 * 对来自服务器的消息的处理函数
 * 即event_listener_add_write_handler()中客户端通信句柄对应的处理函数
 * 
 * 只处理窗口激活消息
 **/
si_t server_message_handler(struct egui_uds* uds_ptr, addr_t arg)
{
	union message msg;
	NOT_USED(arg);

	EGUI_PRINT_INFO("callback server_message_handler() is called");

	if(0 != comm_recv_msg(uds_ptr, &msg))
	{
		EGUI_PRINT_ERROR("failed to recv message from server");
		return SELECTER_RETURN_TYPE_CONTINUE;
	}

	switch(message_get_type(&msg))
	{
	case MESSAGE_TYPE_WINDOW_ACTIVATE:
		EGUI_PRINT_INFO("recieved window activate message!");
		break;
	default:
		EGUI_PRINT_INFO("recieved unknown message, type = %d", (int)message_get_type(&msg));
		break;
	}
	return SELECTER_RETURN_TYPE_CONTINUE;
}