extension TestViewController {func initMpAcc {MpAccClient.shared.setupDatakey("xxx", uuid: "xxx")}func startMeasure() {//Register speed test listenerMpAccClient.shared.registerMeasureCallback(self)let measureConfig = MpMeasureConfig()/// Sliding window measurement time (ms)config.time = 8000/// Latency thresholdconfig.rtt = 60/// Packet loss rate thresholdconfig.loss = 5/// Jitter thresholdconfig.jitter = 15/// Quick startup window timeconfig.quickTime = 2000/// Quick startup latency thresholdconfig.quickRtt = 80/// Measure callback frequencyconfig.interval = 1000/// Acceleration modeconfig.mode = .Redundant/// Enable accelerationMpAccClient.shared.startMeasure(measureConfig: measureConfig)}func stopMeasure() {// Unregister network measurement listenerMpAccClient.shared.unRegisterAccCallback(self);//stop speed measurementMpAccClient.shared.stopMeasure()}}extension TestViewController: MpMeasureCallback {/*** enable dual send* @param code Trigger code 1: Latency anomaly trigger 2: Packet loss anomaly trigger 3: Jitter anomaly trigger*/func onStartMpAcc(code: Int) {appendLog("code:\\(code)")}/*** disable dual send* @param code Trigger code 1: ENI trigger 2: No optimization trigger 3: No network trigger 4: Accelerated network interface and actual active network interface not the same* @msg trigger information*/func onStopMpAcc(code: Int, msg: String) {appendLog("code:\\(code)")}/*** Current network status has no policy available* @param code Trigger code 1: Mobile only 2: wifi only 3: No network 4: Internal error -19: Failed to pull up speed test service -23: Test URL unavailable -25: plugin error -23: Invalid Speed Test -11: Authentication error* @param message trigger information, if message is not empty, mainly use message info*/func onNoPolicy(code: Int, message: String?) {appendLog("code:\\(code) msg: \\(message ?? "")")}/*** Exception in accelerated link (in this case the sdk will proactively disable acceleration and switch back to normal mode)* @param errorCode error code* @param msg error information*/func onAccException(errorCode: Int, msg: String) {appendLog("errorCode:\\(errorCode) msg: \\(msg)")}/*** Bypass udping rtt delay callback* @param type type (0: mobile 1: wifi 2: acc)* @param rtt Delay (ms) Packet loss value is 460*/func onRttChanged(type: Int, rtt: Int) {appendLog("type:\\(type) rtt:\\(rtt)")}/*** Aggregate acceleration status change callback* @param state false: off true: on* @param code 0: normally enabled 1: normal shutdown 2: abnormal shutdown*/func onAccStateChanged(state: Bool, code: Int) {appendLog("state:\\(state) code:\\(code)")}}
フィードバック