修改超时

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){
NSLog("load end") static func loadend(max_ecpm: Double) {
NSLog("loadend: Started with max_ecpm: \(max_ecpm)")
if (isloadend) {
NSLog("load end 10") if isloadend {
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() let directory = "/var/mobile/Documents/ad/append"
mdic["max_ecpm"] = max_ecpm let timestamp = Int(Date().timeIntervalSince1970) //
NSLog("load end b") let filePath = "\(directory)/\(timestamp)" //
let client:XUDPClient = XUDPClient.sharedInstance()
NSLog("load end c") do {
client.hintBlock = { (t:String?) in //
guard let jsonStr = t else { try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true, attributes: nil)
// exit(0)
return
}
let result = convertStringToDictionary(text: jsonStr)
// JSON //
if let resultDict = result, FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil)
let status = resultDict["status"] as? String,
let restart = resultDict["restart"] as? Bool { NSLog("loadend: Created timestamp file at \(filePath)")
} catch {
// NSLog("loadend: Failed to create timestamp file: \(error.localizedDescription)")
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));
} }
} }

View File

@ -1032,60 +1032,32 @@ class YL_NetWorkManager{
callback(); callback();
} ) } )
} }
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)" //
}
let result = convertStringToDictionary(text: jsonStr) do {
//
try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true, attributes: nil)
// JSON //
if let resultDict = result, FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil)
let status = resultDict["status"] as? String,
let restart = resultDict["restart"] as? Bool { NSLog("loadend: Created timestamp file at \(filePath)")
} catch {
// NSLog("loadend: Failed to create timestamp file: \(error.localizedDescription)")
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() {