修改超时
This commit is contained in:
parent
5909bbc526
commit
acd13e8d86
@ -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)
|
||||
|
||||
// 解析返回的 JSON 数据
|
||||
if let resultDict = result,
|
||||
let status = resultDict["status"] as? String,
|
||||
let restart = resultDict["restart"] as? Bool {
|
||||
// 定义目录和文件路径
|
||||
let directory = "/var/mobile/Documents/ad/append"
|
||||
let timestamp = Int(Date().timeIntervalSince1970) // 获取当前时间戳
|
||||
let filePath = "\(directory)/\(timestamp)" // 文件名为时间戳
|
||||
|
||||
// 打印返回的状态
|
||||
NSLog("状态: \(status)")
|
||||
do {
|
||||
// 确保目录存在
|
||||
try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
if restart {
|
||||
// 如果 restart 为 true,重新加载广告
|
||||
NSLog("重新加载广告展示")
|
||||
// BbbAdManager.config.isadload = 0
|
||||
// 调用广告加载的函数
|
||||
// 创建空白文件
|
||||
FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil)
|
||||
|
||||
|
||||
// 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));
|
||||
NSLog("loadend: Created timestamp file at \(filePath)")
|
||||
} catch {
|
||||
NSLog("loadend: Failed to create timestamp file: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 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)
|
||||
|
||||
// 创建空白文件
|
||||
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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user