detection-business/utils/orderSocket.js

34 lines
660 B
JavaScript
Raw Permalink Normal View History

2024-11-09 18:09:46 +08:00
import { startSocketConnect } from '../main.js'
import config from '@/config'
export function connect(userId) {
var socketTask = uni.connectSocket({
url: config.wsUrl+'/websocket/inspection/'+userId,
success(res) {
},
fail(err) {
}
}
);
return socketTask;
}
export function sendSocketMessage(SocketTask) {
if(SocketTask){
SocketTask.send({
data: 'keep connect',
success: res => {
},
fail: err => {
startSocketConnect(uni.getStorageSync('userId'))
},
});
}else{
startSocketConnect(uni.getStorageSync('userId'))
}
}
export function closeSocket(SocketTask) {
SocketTask.close()
2024-11-11 13:18:56 +08:00
}