2***@qq.com
2***@qq.com
  • 发布:2024-01-22 14:51
  • 更新:2024-01-22 14:51
  • 阅读:224

app的websocket 在open函数中没有服务端发送过来的请求头数据

分类:uni-app
let webSocketObject = null;  
const connect = async uuid => new Promise((resolve, reject) => {  
    webSocketObject = uni.connectSocket({  
        url: 'wss://***:8080/wss',  
        header: {  
            UUID: uuid,  
        },  
        success: resolve,  
        fail: reject  
    })  
    webSocketObject.onOpen(res => {  
        console.log('链接成功')  
        console.log(res);  
        console.log(res.header);  
        console.log(res.data ?? '');  
    })  

    webSocketObject.onClose(res => {  
        console.log('连接关闭')  
        console.log(res);  
    })  
    webSocketObject.onError(res => {  
        console.log('连接错误')  
        console.log(res);  
    })  
    webSocketObject.onMessage(res => {  
        console.log('收到服务器内容:');  
        console.log(res.data);  
    })  
})  

uni.onSocketMessage(res => {  
    console.log('收到服务器内容:');  
    console.log(res.data);  
})  

uni.onSocketOpen(res => {  
    console.log('链接成功')  
    console.log(res);  
    console.log(res.header);  
    console.log(res.data ?? '');  
})  
uni.onSocketError(res => {  
    console.log('连接错误')  
    console.log(res);  
})  
uni.onSocketClose(res => {  
    console.log('连接关闭')  
    console.log(res);  
})
2024-01-22 14:51 负责人:无 分享
已邀请:

要回复问题请先登录注册