Autojs Pro7 WebSocket连接Java Netty WebSocket服务器


Java Netty WS 开启服务教程:https://www.yadinghao.com/article/details/202305060007.html

Autojs 代码


function testWSAddress(ws_address){
    let ws = web.newWebSocket(ws_address);
    let result_ws=""
    ws.on("open", (res, ws) => {
        log("WebSocket已连接");
        result_ws= true;
    }).on("failure", (err, res, ws) => {
        log("WebSocket连接失败");
        console.error(err);
        result_ws= false;
    })
    sleep(3000)
    return result_ws
}
console.show()
toastLog(testWSAddress(ws_address="ws://192.168.3.170:8686"))


连接成功示意图

image.png

Java Netty WS 开启服务教程:https://www.yadinghao.com/article/details/202305060007.html

Autojs 代码


function testWSAddress(ws_address){
    let ws = web.newWebSocket(ws_address);
    let result_ws=""
    ws.on("open", (res, ws) => {
        log("WebSocket已连接");
        result_ws= true;
    }).on("failure", (err, res, ws) => {
        log("WebSocket连接失败");
        console.error(err);
        result_ws= false;
    })
    sleep(3000)
    return result_ws
}
console.show()
toastLog(testWSAddress(ws_address="ws://192.168.3.170:8686"))


连接成功示意图

image.png

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在