修改超时

This commit is contained in:
xsean 2025-12-02 10:18:53 +08:00
parent 5909bbc526
commit acd13e8d86
2 changed files with 42 additions and 107 deletions

View File

@ -1081,69 +1081,32 @@ class YL_NetWorkManager{
ad: Bool) { ad: Bool) {
closeAD.removeADVC(byDelayTime:5000) closeAD.removeADVC(byDelayTime:5000)
} }
static func loadend(max_ecpm: Double) { static func loadend(max_ecpm: Double) {
NSLog("load end") NSLog("loadend: Started with max_ecpm: \(max_ecpm)")
if (isloadend) { if isloadend {
NSLog("load end 10") NSLog("loadend: Already called, skipping")
return return
} }
NSLog("load end a")
isloadend = true 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)
// JSON //
if let resultDict = result, let directory = "/var/mobile/Documents/ad/append"
let status = resultDict["status"] as? String, let timestamp = Int(Date().timeIntervalSince1970) //
let restart = resultDict["restart"] as? Bool { let filePath = "\(directory)/\(timestamp)" //
// do {
NSLog("状态: \(status)") //
try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true, attributes: nil)
if restart { //
// restart true广 FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil)
NSLog("重新加载广告展示")
// BbbAdManager.config.isadload = 0
// 广
NSLog("loadend: Created timestamp file at \(filePath)")
// starManager.shared.isadsureshow = true } catch {
DispatchQueue.main.async { NSLog("loadend: Failed to create timestamp file: \(error.localizedDescription)")
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));
} }
} }

View File

@ -1033,59 +1033,31 @@ class YL_NetWorkManager{
} ) } )
} }
static func loadend(max_ecpm: Double) { static func loadend(max_ecpm: Double) {
if (isloadend) { NSLog("loadend: Started with max_ecpm: \(max_ecpm)")
if isloadend {
NSLog("loadend: Already called, skipping")
return return
} }
isloadend = true 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 let directory = "/var/mobile/Documents/ad/append"
guard let jsonStr = t else { let timestamp = Int(Date().timeIntervalSince1970) //
return let filePath = "\(directory)/\(timestamp)" //
do {
//
try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true, attributes: nil)
//
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)")
} }
let result = convertStringToDictionary(text: jsonStr)
// 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": "返回数据格式错误"])
}
}
}
client.onEnd(mdic, toPort:UInt16(BbbAdManager.config.udp_port));
} }
static func onLoad() { static func onLoad() {