extension TestViewController {func initMpAcc {MpAccClient.shared.setupDatakey("xxx", uuid: "xxx")}func startMeasure() {//注册测速监听MpAccClient.shared.registerMeasureCallback(self)let measureConfig = MpMeasureConfig()/// 滑动窗口测量时间 (ms)config.time = 8000/// 时延阈值config.rtt = 60/// 丢包率阈值config.loss = 5/// 抖动阈值config.jitter = 15/// 快启动窗口时间config.quickTime = 2000/// 快启动时延阈值config.quickRtt = 80/// 测量回调频率config.interval = 1000/// 加速模式config.mode = .Redundant/// 开启加速MpAccClient.shared.startMeasure(measureConfig: measureConfig)}func stopMeasure() {//注销网络测量监听MpAccClient.shared.unRegisterAccCallback(self);//停止测速MpAccClient.shared.stopMeasure()}}extension TestViewController: MpMeasureCallback {/*** 建议开启双发* @param code 触发码 1:时延异常触发 2:丢包率异常触发 3:抖动异常触发*/func onStartMpAcc(code: Int) {appendLog("code:\\(code)")}/*** 建议关闭双发* @param code 触发码 1:单网卡触发 2:无优化触发 3:无网络触发 4:加速网卡和实际活跃网卡不一致* @msg 触发信息*/func onStopMpAcc(code: Int, msg: String) {appendLog("code:\\(code)")}/*** 当前网络状态无策略可用* @param code 触发码 1: 单moblie 2:单wifi 3: 无网 4:内部错误 -19: 拉起测速服务失败 -23: 测试地址无效 -25:plugin错误 -23:无效测速网 -11 认证错误* @param message 触发信息,若message不为空,则以message信息为主*/func onNoPolicy(code: Int, message: String?) {appendLog("code:\\(code) msg: \\(message ?? "")")}/*** 加速链路出现异常(此种情况sdk会主动关闭加速,切回正常模式)* @param errorCode 错误码* @param msg 错误信息*/func onAccException(errorCode: Int, msg: String) {appendLog("errorCode:\\(errorCode) msg: \\(msg)")}/*** 旁路udping rtt时延回调* @param type 种类(0:mobile 1:wifi 2:acc )* @param rtt 时延(ms) 丢包值为460*/func onRttChanged(type: Int, rtt: Int) {appendLog("type:\\(type) rtt:\\(rtt)")}/*** 聚合加速状态改变回调* @param state false:关闭 true:打开* @param code 0:正常开启 1:正常关闭 2:异常关闭*/func onAccStateChanged(state: Bool, code: Int) {appendLog("state:\\(state) code:\\(code)")}}
文档反馈