出售本站【域名】【外链】

autojs websocket 核心代码,tiktok云控技术

阅读: 22 发表于 2024-11-02 01:46

 

当前位置:老马黑科技 > 编程宅男 > autojs > 正文

autojs websocket 焦点代码,tiktok云控技术

autojs websocket 焦点示例代码,云控技术

//初始化办法 function recordInit(scriptName){ //let ipInfoJson = getIP() // let ip = ipInfoJson.cip // let location = ipInfoJsonssame let deZZZiceIMEI = '',deZZZiceBrand='',deZZZiceModel='',Androidxer='',deZZZiceWH='',deZZZiceBoard='',deZZZiceMac='',AndroidId='' try { deZZZiceBrand = deZZZice.brand;//制造厂商 deZZZiceBoard = deZZZice.board;//主板 deZZZiceMac = deZZZice.getMacAddress()//Mac地址 AndroidId = deZZZice.getAndroidId()//安卓ID data={ "category":1, "uuid":"55421", "deZZZice_code":"086", "configure":"5656E", "owner":"1", "model":deZZZice.model, "release": deZZZice.release, "memory":~~(deZZZice.getAZZZailMem()/1024/1024)+'MB', "imei":deZZZice.getIMEI(), "width":deZZZice.width, "height":deZZZice.height, "battery":deZZZice.getBattery() } ZZZar token=setting.storage.get('access_token') ZZZar res = ht.postJson(setting.api_domain+'deZZZice/?access-token='+token,data); if(res.statusCode==200){ log('已添加') return true } else if(res.statusCode==201){ log("已更新") return true }else{ log("添加方法失败") return false } } catch (error) { log(error) return false; } } ZZZar ws = { run:function(){ setting.ws_status =true; console.log('运用软件的历程中,请确保您的网络流畅~') console.log('Websocket连贯中..') setting.ws = web.newWebSocket(setting.websocket_domain, { //eZZZentThread: 'this' }); //ws监听 setting.ws.on("open", (res) => { log("WebSocket连贯乐成!"); //心跳检测 let hi={'type':'connect','uuid':'033246','deZZZice_code':'003'} setting.ws.send(JSON.stringify(hi)); setting.heartbeat = threads.start(function(){ setInterZZZal(function(){ console.log('发送心跳包'); }, 10000); }); }).on("failure", (err, res) => { // 封锁心跳包线程 setting.heartbeat.interrupt(); //console.error(err); setting.ws_status =false; // 断线重连 if(setting.allow_ws_re){ console.error('取总控的连贯已断开,五秒后重连...'); sleep(5000) this.run() } // 扭转“连贯总控”颜涩 ui.run(function(){ ui.start.setBackgroundColor(colors.parseColor("#d6d7d7")) ui.start.teVt("连贯总控") ui.start.setTeVtColor(colors.parseColor("#000000")) }); //alert("提示","ws通道已断开!"); //eVit(); }).on("closing", (code, reason) => { log("WebSocket封锁中"); }).on("teVt", (teVt) => { log("支到音讯") try { let data = JSON.parse(teVt); switch(data.type){ case 'init': console.log('等候总控响应...') ZZZar ret=recordInit('init') console.error("初始化返回:"+ret ) if(ret){ toastLog('乐成取总控建设连贯') console.info('大罪成功,您可以正在总控端控制该末端了~'); // 扭转"连贯总控"颜涩 ui.run(function(){ // 假如正在主界面 if(ui.start){ if(setting.sys_name == "闲鱼助手"){ ui.start.setBackgroundColor(colors.parseColor("#009688")) }else{ ui.start.setTeVtColor(colors.parseColor("#ffffff")) ui.start.setBackgroundColor(colors.parseColor(setting.baozeng_colour)) } ui.start.teVt("已连贯") } }); deZZZice.ZZZibrate(500);//震动700毫秒 }else{ setting.ws_status =false; let err_msg = r['msg'] alert(err_msg);console.error(err_msg) } break; case 'start': log('接到任务:',json.task) let sid = json.sid stopEngine() try {try {if(main_thread) main_thread.interrupt()} catch (error) { }} catch (error) { } if(getScriptConfig(sid)){ send_Log('[初步运止]'+json.task,true) main_thread = threads.start(function () { doTask(sid) }); }else{ send_Log('[启动失败]方法获与脚原配置失败!',true) } break; case 'web_to_aj_command': //执止web发来的号令 //console.warn(data.task_type + '('+data.task_id+')'); threads.start(function () { eZZZal(data.task_type + '('+data.task_id+')'); console.log('等候总控号令中....') }); break; case 'eVec_command': break; case 'NO': log(data.msg) toast(data.msg) setting.ws.closed(); break; case 'web_to_aj_chat_message': //web_to_aj_chat_message console.log(data) // console.log('web_to_aj_chat_message') setting.message.push({name:data['name'],message:data['message']}) break; default: console.log('defautl') console.log(data) } } catch (error) { log("解析返回来离去的数据舛错") log(error) } }).on("closed", (code, reason) => { //log("WebSocket已封锁: code = %d, reason = %s", code, reason); setting.ws_status =false; alert("提示","ws通道已断开2"); console.error('ws通道已断开2') //eVit(); }); } } // 函数导出 module.eVports = ws;

标签:autojs

热点推荐

最新发布

友情链接