检测优化
This commit is contained in:
parent
0c6cbb7be9
commit
93b222ee38
33
utils/orderSocket.js
Normal file
33
utils/orderSocket.js
Normal file
@ -0,0 +1,33 @@
|
||||
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()
|
||||
}
|
Loading…
Reference in New Issue
Block a user