Commit b52edb5d by 周志凯

close websocket

1 parent bb6067e3
......@@ -1121,6 +1121,7 @@
{ label: '店员对比', value: 1 },
{ label: '顾客对比', value: 2 }
],
socket: {},
results: [],
startTiming: 0,
endTiming: 0,
......@@ -1838,6 +1839,10 @@
},
/////////////////////////////特征重提////////////////////////////////////////////////
onSearchClick: function() {
this.socket && this.socket.close()
this.results = []
this.startTiming = 0
this.endTiming = 0
const TAB_API = {
revisitFeature: () => '/mall/feature',
rebuildFeatureLib: (val) => {
......@@ -1967,26 +1972,26 @@
wsUrl = webSockUrl || window.location.host,
socketUrl = "ws://" + wsUrl + "/recal/schedule/" + scheduleType
console.log('[socketUrl]:', socketUrl)
var socket = new ws(socketUrl)
socket.onconnecting = function (ev) {
self.socket = new ws(socketUrl)
self.socket.onconnecting = function (ev) {
console.log('socket:onconnecting', ev)
}
socket.onopen = function(ev) {
self.socket.onopen = function(ev) {
console.log('socket:onopen', ev)
callback && callback(callbackUrlPath, callbackParam)
}
socket.onclose = function(ev) {
self.socket.onclose = function(ev) {
console.log('socket:onclose', ev)
// log('WebSocket Closed!!')
}
socket.onmessage = function(ev) {
self.socket.onmessage = function(ev) {
console.log('socket:onmessage', ev)
var msg = JSON.parse(ev.data)
console.log('[onmessage]:', msg)
self.dealMessage(msg)
if (msg.stepCount === 1) {
this.endTiming = new Date()
socket.close()
self.socket.close()
}
}
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!