Commit b52edb5d by 周志凯

close websocket

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