修改
This commit is contained in:
parent
088617646f
commit
006e8692e8
10
ips.txt
10
ips.txt
@ -1 +1,9 @@
|
||||
192.168.31.254
|
||||
172.29.133.11
|
||||
172.29.133.12
|
||||
172.29.133.17
|
||||
172.29.133.10
|
||||
172.29.133.13
|
||||
172.29.133.14
|
||||
172.29.133.15
|
||||
172.29.133.16
|
||||
172.29.133.18
|
||||
@ -24,18 +24,17 @@
|
||||
|
||||
#pragma mark - Singleton
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
|
||||
static XUDPClient *_sharedInstance = nil;
|
||||
static dispatch_once_t oncePredicate;
|
||||
dispatch_once(&oncePredicate, ^{
|
||||
_sharedInstance = [[XUDPClient alloc] init];
|
||||
_sharedInstance = [super allocWithZone:zone];
|
||||
});
|
||||
return _sharedInstance;
|
||||
}
|
||||
|
||||
// ⭐️ 防止通过alloc/init创建新实例
|
||||
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
|
||||
return [XUDPClient sharedInstance];
|
||||
+ (instancetype)sharedInstance {
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||
|
||||
@ -847,7 +847,7 @@ class YL_NetWorkManager{
|
||||
errorMsg:String = ""
|
||||
) {
|
||||
var mdic: [String: Any] = [:]
|
||||
|
||||
NSLog("upload load log1")
|
||||
mdic["deviceId"] = BbbAdManager.config.adbrush_deviceid
|
||||
mdic["gaid"] = self.getGaid()
|
||||
mdic["localIp"] = BbbAdManager.config.adbrush_localip
|
||||
@ -908,6 +908,7 @@ class YL_NetWorkManager{
|
||||
} catch {
|
||||
print("Error serializing JSON: \(error.localizedDescription)")
|
||||
}
|
||||
NSLog("upload load log2")
|
||||
}
|
||||
|
||||
|
||||
@ -1018,16 +1019,21 @@ class YL_NetWorkManager{
|
||||
closeAD.removeADVC(byDelayTime:5000)
|
||||
}
|
||||
static func loadend(max_ecpm:Double){
|
||||
NSLog("load end")
|
||||
|
||||
if (isloadend) {
|
||||
NSLog("load end 10")
|
||||
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 {
|
||||
return
|
||||
@ -1040,11 +1046,11 @@ class YL_NetWorkManager{
|
||||
let restart = resultDict["restart"] as? Bool {
|
||||
|
||||
// 打印返回的状态
|
||||
print("状态: \(status)")
|
||||
NSLog("状态: \(status)")
|
||||
|
||||
if restart {
|
||||
// 如果 restart 为 true,重新加载广告
|
||||
print("重新加载广告展示")
|
||||
NSLog("重新加载广告展示")
|
||||
// BbbAdManager.config.isadload = 0
|
||||
// 调用广告加载的函数
|
||||
|
||||
@ -1057,20 +1063,23 @@ class YL_NetWorkManager{
|
||||
|
||||
} else {
|
||||
// restart 为 false,不需要处理
|
||||
print("不需要重新加载广告,程序后续会被杀掉")
|
||||
NSLog("不需要重新加载广告,程序后续会被杀掉")
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "不需要重新加载广告,程序后续会被杀掉"])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print("返回数据格式错误")
|
||||
NSLog("返回数据格式错误")
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "返回数据格式错误"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client.onEnd(mdic, toPort:UInt16(BbbAdManager.config.udp_port));
|
||||
NSLog("load end1")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
NSLog("load end2")
|
||||
client.onEnd(mdic, toPort:UInt16(BbbAdManager.config.udp_port));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -102,10 +102,7 @@ class AdItem :NSObject,MAAdDelegate{
|
||||
|
||||
func changeStatus(st:Int) {
|
||||
self.status = st
|
||||
onStatusChange?(self.interstitialAdID, st, self.ecpm)
|
||||
if (BbbAdManager.config.washParam && st>=2) {
|
||||
YL_NetWorkManager.loadend(max_ecpm: 0)
|
||||
}
|
||||
onStatusChange?(self.interstitialAdID, st, self.ecpm)
|
||||
}
|
||||
func getLoadTime() -> Int {
|
||||
var time = 0
|
||||
@ -146,9 +143,9 @@ class AdItem :NSObject,MAAdDelegate{
|
||||
|
||||
// 计算并打印加载时间
|
||||
var time = 0
|
||||
if let startTime = startLoadTime {
|
||||
if let startTime: DispatchTime = startLoadTime {
|
||||
let loadDuration = calculateElapsedTime(since: startTime)
|
||||
print("广告 \(ad.adUnitIdentifier) 加载时间: \(loadDuration) ms")
|
||||
NSLog("广告 \(ad.adUnitIdentifier) 加载时间: \(loadDuration) ms")
|
||||
time = loadDuration
|
||||
}
|
||||
|
||||
@ -173,7 +170,7 @@ class AdItem :NSObject,MAAdDelegate{
|
||||
var time = 0
|
||||
if let startTime = startLoadTime {
|
||||
let loadDuration = calculateElapsedTime(since: startTime)
|
||||
print("广告 \(adUnitIdentifier) 加载时间: \(loadDuration) ms")
|
||||
NSLog("广告 \(adUnitIdentifier) 加载时间: \(loadDuration) ms")
|
||||
time = loadDuration
|
||||
}
|
||||
DispatchQueue.global(qos: .utility).async { [weak self] in
|
||||
@ -188,7 +185,7 @@ class AdItem :NSObject,MAAdDelegate{
|
||||
func didDisplay(_ ad: MAAd) {
|
||||
|
||||
|
||||
print("成功展示了ad\(ad.adUnitIdentifier)")
|
||||
NSLog("成功展示了ad\(ad.adUnitIdentifier)")
|
||||
// NotificationCenter.default.post(name: .adDidDisplay, object: nil, userInfo: ["adId": ad.adUnitIdentifier])
|
||||
|
||||
// let currentIDFV = UIDevice.current.identifierForVendor?.uuidString
|
||||
@ -212,17 +209,17 @@ class AdItem :NSObject,MAAdDelegate{
|
||||
|
||||
func didHide(_ ad: MAAd) {
|
||||
changeStatus(st: 4)
|
||||
print("成功关闭广告\(ad.adUnitIdentifier)")
|
||||
NSLog("成功关闭广告\(ad.adUnitIdentifier)")
|
||||
onAdClosed?()
|
||||
}
|
||||
|
||||
func didClick(_ ad: MAAd) {
|
||||
print("点击了广告\(ad.adUnitIdentifier)")
|
||||
NSLog("点击了广告\(ad.adUnitIdentifier)")
|
||||
}
|
||||
|
||||
func didFail(toDisplay ad: MAAd, withError error: MAError) {
|
||||
changeStatus(st: 6)
|
||||
print("展示广告\(ad.adUnitIdentifier),\(error)失败")
|
||||
NSLog("展示广告\(ad.adUnitIdentifier),\(error)失败")
|
||||
NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "展示广告\(ad.adUnitIdentifier),\(error)失败"])
|
||||
//self.onAdClosed!()
|
||||
}
|
||||
@ -248,7 +245,7 @@ class BbbAdManager: NSObject {
|
||||
|
||||
var openADTimer:Timer?
|
||||
let kOpenADPerSec: CGFloat = 0.1 // 假设的秒数
|
||||
let kOpenAdCTimeLength: CGFloat = 30 // 假设的超时时长
|
||||
let kOpenAdCTimeLength: CGFloat = 40 // 假设的超时时长
|
||||
|
||||
static var totalTimeC: CGFloat = 0.0
|
||||
|
||||
@ -294,19 +291,19 @@ class BbbAdManager: NSObject {
|
||||
if #available(iOS 14, *) {
|
||||
IDFA.shared.checkATT { idfa in
|
||||
if let idfa = idfa {
|
||||
print("IDFA: \(idfa)")
|
||||
NSLog("IDFA: \(idfa)")
|
||||
BbbAdManager.config.idfa = idfa
|
||||
} else {
|
||||
print("无法获取 IDFA")
|
||||
NSLog("无法获取 IDFA")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IDFA.shared.getIDFAForOlderVersions { idfa in
|
||||
if let idfa = idfa {
|
||||
print("IDFA: \(idfa)")
|
||||
NSLog("IDFA: \(idfa)")
|
||||
BbbAdManager.config.idfa = idfa
|
||||
} else {
|
||||
print("无法获取 IDFA")
|
||||
NSLog("无法获取 IDFA")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -352,7 +349,9 @@ class BbbAdManager: NSObject {
|
||||
}
|
||||
func loadAd2() {
|
||||
for(index,ad) in self.adItems.values.enumerated() {
|
||||
ad.loadInterstitialAd()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + Double(index) * 1) {
|
||||
ad.loadInterstitialAd()
|
||||
}
|
||||
}
|
||||
}
|
||||
func loadAd() {
|
||||
@ -378,10 +377,11 @@ class BbbAdManager: NSObject {
|
||||
}
|
||||
for (_, ad) in BbbAdManager.shared.adItems {
|
||||
if(ad.status <= 1) {
|
||||
let loadTime = ad.getLoadTime()
|
||||
if (loadTime > 15000) {
|
||||
ad.failLoad(forAdUnitIdentifier: ad.interstitialAdID, withError: "load ad time out > 15s")
|
||||
}
|
||||
// let loadTime = ad.getLoadTime()
|
||||
// NSLog("check loadtime\(loadTime)")
|
||||
// if (loadTime > 30000) {
|
||||
// ad.failLoad(forAdUnitIdentifier: ad.interstitialAdID, withError: "load ad time out > 30s")
|
||||
// }
|
||||
return false
|
||||
}
|
||||
if (ad.status == 2 && BbbAdManager.config.washParam) {
|
||||
@ -417,9 +417,12 @@ class BbbAdManager: NSObject {
|
||||
BbbAdManager.totalTimeC += kOpenADPerSec
|
||||
|
||||
if BbbAdManager.shared.isEnd() || BbbAdManager.totalTimeC >= kOpenAdCTimeLength {
|
||||
NSLog("xyz 1")
|
||||
openADTimer?.invalidate()
|
||||
openADTimer = nil
|
||||
NSLog("xyz 2")
|
||||
YL_NetWorkManager.loadend(max_ecpm: 0)
|
||||
NSLog("xyz 3")
|
||||
}
|
||||
|
||||
if BbbAdManager.shared.isshow == false{
|
||||
|
||||
@ -60,9 +60,9 @@ class YL_PlayVC: UIViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BbbAdManager.shared.start()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 4 ) {
|
||||
BbbAdManager.shared.start()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ class AdItem :NSObject, ATInterstitialDelegate {
|
||||
func didFailBiddingADSource(withPlacementID placementID: String!,extra: [AnyHashable : Any]?, error: (any Error)!) {
|
||||
// BbbAdManager.config.loadcount += 1
|
||||
NSLog("XS- load \(String(describing: placementID)) err.... :\(String(describing: error))")
|
||||
/*
|
||||
|
||||
var time = 0
|
||||
|
||||
if let startTime = startLoadTime {
|
||||
@ -228,7 +228,7 @@ class AdItem :NSObject, ATInterstitialDelegate {
|
||||
guard self != nil else { return }
|
||||
YL_NetWorkManager.uploadAD_Load(adid: placementID, ecpm: 0.0 , network: "", countryCode: "", platformResponseTime: TimeInterval(time/1000) , dsp: "MTG", loadTime: time,errMsg: "\(String(describing: error))")
|
||||
}
|
||||
*/
|
||||
|
||||
NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "bidding error:\(String(describing: placementID) ),\(String(describing: error)) 失败"])
|
||||
// self.onAdClosed()
|
||||
// changeStatus(st: 5)
|
||||
@ -473,9 +473,11 @@ class BbbAdManager: NSObject {
|
||||
|
||||
}
|
||||
}else{
|
||||
for (_, adId) in BbbAdManager.config.adids.enumerated() {
|
||||
for (index, adId) in BbbAdManager.config.adids.enumerated() {
|
||||
NSLog("XS- ad load start:\(BbbAdManager.config.linkId) - \(adId)")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + Double(index) * 1) {
|
||||
BbbAdManager.shared.add(adId: adId)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user