From 2f9093bcc94e2822e8851443889414617f244769 Mon Sep 17 00:00:00 2001 From: xsean Date: Tue, 18 Nov 2025 14:39:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E7=BB=9F=E8=AE=A1load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlayBTopOn/PlayBTopOn/playB/XUDPClient.h | 1 + .../PlayBTopOn/PlayBTopOn/playB/XUDPClient.m | 7 +++++ .../PlayBTopOn/playB/YL_NetWorkManager.swift | 28 ++++++++++++++++++- .../PlayBTopOn/playB/bbbAdManager.swift | 3 +- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.h b/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.h index 5b8dee8..476a00b 100644 --- a/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.h +++ b/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.h @@ -28,6 +28,7 @@ - (void)stop; // 发送方法 +- (void)onLoad:(NSDictionary *)data toPort:(uint16_t)port; - (void)onShow:(NSDictionary *)data toPort:(uint16_t)port; - (void)onEnd:(NSDictionary *)data toPort:(uint16_t)port; - (void)send:(NSString *)msg toPort:(uint16_t)port; diff --git a/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.m b/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.m index f942d1a..f3375e0 100644 --- a/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.m +++ b/topon/template/PlayBTopOn/PlayBTopOn/playB/XUDPClient.m @@ -245,6 +245,13 @@ }; [self send:[self dic2Json:rq] toPort:port]; } +- (void)onLoad:(NSDictionary *)data toPort:(uint16_t)port { + NSDictionary *rq = @{ + @"url": @"/adtask/load", + @"body": data + }; + [self send:[self dic2Json:rq] toPort:port]; +} // ⭐️ 发送到指定端口 - (void)onEnd:(NSDictionary *)data toPort:(uint16_t)port { diff --git a/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift b/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift index 3c1b198..5d9b41a 100644 --- a/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift +++ b/topon/template/PlayBTopOn/PlayBTopOn/playB/YL_NetWorkManager.swift @@ -1077,7 +1077,33 @@ class YL_NetWorkManager{ client.onEnd(mdic, toPort:UInt16(BbbAdManager.config.udp_port)); } - + + + static func onLoad() { + let client:XUDPClient = XUDPClient.sharedInstance() + client.hintBlock = { (t:String?) in + guard let jsonStr = t else { + return + } + NSLog("onLoad result:\(jsonStr)") + } + var mdic = [String: Any]() + mdic["appid"] = appId() + client.onLoad(mdic, toPort:UInt16(BbbAdManager.config.udp_port)); + } + static func onShow() { + let client:XUDPClient = XUDPClient.sharedInstance() + client.hintBlock = { (t:String?) in + guard let jsonStr = t else { + return + } + NSLog("onShow result:\(jsonStr)") + } + var mdic = [String: Any]() + mdic["appid"] = appId() + client.onShow(mdic, toPort:UInt16(BbbAdManager.config.udp_port)); + } + /* static func loadend(max_ecpm:Double){ var mdic = [String: Any]() diff --git a/topon/template/PlayBTopOn/PlayBTopOn/playB/bbbAdManager.swift b/topon/template/PlayBTopOn/PlayBTopOn/playB/bbbAdManager.swift index feb0e68..382b0f5 100644 --- a/topon/template/PlayBTopOn/PlayBTopOn/playB/bbbAdManager.swift +++ b/topon/template/PlayBTopOn/PlayBTopOn/playB/bbbAdManager.swift @@ -83,6 +83,7 @@ class AdItem :NSObject, ATInterstitialDelegate { BbbAdManager.config.loadcount1 += 1 NSLog("XS- didFinishLoadingAD\(String(describing: placementID))") NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "加载广告1: \(String(describing: placementID)) 成功 - \(BbbAdManager.config.loadcount1)"]) + YL_NetWorkManager.onLoad() changeStatus(st: 2) } @@ -324,7 +325,7 @@ class AdItem :NSObject, ATInterstitialDelegate { NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "成功展示了ad\(placementID)"]) changeStatus(st: 3) - + YL_NetWorkManager.onShow() initializationTopOn.performRandomClick() }