From acd13e8d86bc0509a30a021626602cf56a1151d0 Mon Sep 17 00:00:00 2001 From: xsean Date: Tue, 2 Dec 2025 10:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../playbtest/PlayB/YL_NetWorkManager.swift | 81 +++++-------------- .../PlayBTopOn/playB/YL_NetWorkManager.swift | 68 +++++----------- 2 files changed, 42 insertions(+), 107 deletions(-) diff --git a/max/template/playbtest/playbtest/PlayB/YL_NetWorkManager.swift b/max/template/playbtest/playbtest/PlayB/YL_NetWorkManager.swift index ef970b7..a09f424 100644 --- a/max/template/playbtest/playbtest/PlayB/YL_NetWorkManager.swift +++ b/max/template/playbtest/playbtest/PlayB/YL_NetWorkManager.swift @@ -1081,69 +1081,32 @@ class YL_NetWorkManager{ ad: Bool) { closeAD.removeADVC(byDelayTime:5000) } - static func loadend(max_ecpm:Double){ - NSLog("load end") - - if (isloadend) { - NSLog("load end 10") + + static func loadend(max_ecpm: Double) { + NSLog("loadend: Started with max_ecpm: \(max_ecpm)") + + if isloadend { + NSLog("loadend: Already called, skipping") return } - NSLog("load end a") + isloadend = true - var mdic = [String: Any]() - mdic["appid"] = appId() - mdic["idfa"] = getIdfa() - mdic["max_ecpm"] = max_ecpm - NSLog("load end b") - let client:XUDPClient = XUDPClient.sharedInstance() - NSLog("load end c") - client.hintBlock = { (t:String?) in - guard let jsonStr = t else { - // exit(0) - return - } - let result = convertStringToDictionary(text: jsonStr) + + // 定义目录和文件路径 + let directory = "/var/mobile/Documents/ad/append" + let timestamp = Int(Date().timeIntervalSince1970) // 获取当前时间戳 + let filePath = "\(directory)/\(timestamp)" // 文件名为时间戳 + + do { + // 确保目录存在 + try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true, attributes: nil) - // 解析返回的 JSON 数据 - if let resultDict = result, - let status = resultDict["status"] as? String, - let restart = resultDict["restart"] as? Bool { - - // 打印返回的状态 - NSLog("状态: \(status)") - - if restart { - // 如果 restart 为 true,重新加载广告 - NSLog("重新加载广告展示") - // BbbAdManager.config.isadload = 0 - // 调用广告加载的函数 - - - // starManager.shared.isadsureshow = true - DispatchQueue.main.async { - NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "重新加载广告展示"]) - } - - - } else { - // restart 为 false,不需要处理 - NSLog("不需要重新加载广告,程序后续会被杀掉") - DispatchQueue.main.async { - NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "不需要重新加载广告,程序后续会被杀掉"]) - } - } - } else { - NSLog("返回数据格式错误") - DispatchQueue.main.async { - NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "返回数据格式错误"]) - } - } - //exit(0) - } - NSLog("load end1") - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - NSLog("load end2") - client.onEnd(mdic, toPort:UInt16(BbbAdManager.config.udp_port)); + // 创建空白文件 + FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil) + + NSLog("loadend: Created timestamp file at \(filePath)") + } catch { + NSLog("loadend: Failed to create timestamp file: \(error.localizedDescription)") } } diff --git a/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift b/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift index 8c7ee56..5a0f3e9 100644 --- a/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift +++ b/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift @@ -1032,60 +1032,32 @@ class YL_NetWorkManager{ callback(); } ) } - static func loadend(max_ecpm:Double){ - if (isloadend) { + static func loadend(max_ecpm: Double) { + NSLog("loadend: Started with max_ecpm: \(max_ecpm)") + + if isloadend { + NSLog("loadend: Already called, skipping") return } + isloadend = true - var mdic = [String: Any]() - mdic["appid"] = appId() - mdic["idfa"] = getIdfa() - mdic["max_ecpm"] = max_ecpm - let client:XUDPClient = XUDPClient.sharedInstance() - client.hintBlock = { (t:String?) in - guard let jsonStr = t else { - return - } - let result = convertStringToDictionary(text: jsonStr) + // 定义目录和文件路径 + let directory = "/var/mobile/Documents/ad/append" + let timestamp = Int(Date().timeIntervalSince1970) // 获取当前时间戳 + let filePath = "\(directory)/\(timestamp)" // 文件名为时间戳 + + do { + // 确保目录存在 + try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true, attributes: nil) - // 解析返回的 JSON 数据 - if let resultDict = result, - let status = resultDict["status"] as? String, - let restart = resultDict["restart"] as? Bool { - - // 打印返回的状态 - print("状态: \(status)") - - if restart { - // 如果 restart 为 true,重新加载广告 - print("重新加载广告展示") - // BbbAdManager.config.isadload = 0 - // 调用广告加载的函数 - - - // starManager.shared.isadsureshow = true - DispatchQueue.main.async { - NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "重新加载广告展示"]) - } - - - } else { - // restart 为 false,不需要处理 - print("不需要重新加载广告,程序后续会被杀掉") - DispatchQueue.main.async { - NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "不需要重新加载广告,程序后续会被杀掉"]) - } - } - } else { - print("返回数据格式错误") - DispatchQueue.main.async { - NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "返回数据格式错误"]) - } - } + // 创建空白文件 + FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil) + + NSLog("loadend: Created timestamp file at \(filePath)") + } catch { + NSLog("loadend: Failed to create timestamp file: \(error.localizedDescription)") } - - client.onEnd(mdic, toPort:UInt16(BbbAdManager.config.udp_port)); } static func onLoad() {