第一次提交
This commit is contained in:
40
java/webSoket.txt
Normal file
40
java/webSoket.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
mounted() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
init: function() {
|
||||
if (typeof (WebSocket) === 'undefined') {
|
||||
alert('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>socket')
|
||||
} else {
|
||||
// ʵ<><CAB5><EFBFBD><EFBFBD>socket
|
||||
this.socket = new WebSocket(this.path)
|
||||
// <20><><EFBFBD><EFBFBD>socket<65><74><EFBFBD><EFBFBD>
|
||||
this.socket.onopen = this.open
|
||||
// <20><><EFBFBD><EFBFBD>socket<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
this.socket.onerror = this.error
|
||||
// <20><><EFBFBD><EFBFBD>socket<65><74>Ϣ
|
||||
this.socket.onmessage = this.getMessage
|
||||
}
|
||||
},
|
||||
open: function() {
|
||||
console.log('socket<65><74><EFBFBD>ӳɹ<D3B3>')
|
||||
},
|
||||
error: function() {
|
||||
console.log('<27><><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>')
|
||||
},
|
||||
getMessage: function(msg) {
|
||||
debugger
|
||||
this.allJson = JSON.parse(msg.data)
|
||||
this.crueList = this.allJson.msg.cureJson
|
||||
this.ovenList = this.allJson.msg.ovenJson
|
||||
this.empList = this.allJson.msg.empJson
|
||||
this.allTaskList = this.allJson.msg.allTask
|
||||
this.unDoneTask = this.allJson.msg.unTask
|
||||
},
|
||||
send: function() {
|
||||
// eslint-disable-next-line no-undef
|
||||
this.socket.send(params)
|
||||
},
|
||||
close: function() {
|
||||
console.log('socket<65>Ѿ<EFBFBD><D1BE>ر<EFBFBD>')
|
||||
},
|
||||
Reference in New Issue
Block a user