bool ParseChatRoomEnterCallbackResultInfo(const std::string& result, ChatRoomInfo& room_info, ChatRoomMemberInfo& my_info)
{
	Json::Value values;
	Json::Reader reader;
	if (reader.parse(result, values) && values.isObject())
	{
		room_info.ParseFromJsonValue(values[kNIMChatRoomEnterCallbackKeyRoomInfo]);
		my_info.ParseFromJsonValue(values[kNIMChatRoomEnterCallbackKeyMyInfo]);
		return true;
	}
	return false;
}
bool ParseChatRoomMemberInfos(const std::string& infos_json_str, std::list<ChatRoomMemberInfo>& infos)
{
	Json::Value values;
	Json::Reader reader;
	if (reader.parse(infos_json_str, values) && values.isArray())
	{
		int count = values.size();
		for (int i = 0; i < count; i++)
		{
			ChatRoomMemberInfo info;
			info.ParseFromJsonValue(values[i]);
			infos.push_back(info);
		}
		return true;
	}
	return false;
}
Пример #3
0
static void CallbackSetMemberAtribute(__int64 room_id, int error_code, const char *result, const char *json_extension, const void *user_data)
{
	if (user_data)
	{
		ChatRoom::SetMemberAttributeCallback *cb = (ChatRoom::SetMemberAttributeCallback*)user_data;
		if (*cb)
		{
			Json::Value value;
			Json::Reader reader;
			if (reader.parse(PCharToString(result), value) && value.isObject())
			{
				ChatRoomMemberInfo info;
				info.ParseFromJsonValue(value);
				(*cb)(room_id, error_code, info);
				return;
			}
			(*cb)(room_id, error_code, ChatRoomMemberInfo());
		}
	}
}