|
@@ -11,16 +11,18 @@ function MagicWebSocket(url) {
|
|
}
|
|
}
|
|
this.listeners = {};
|
|
this.listeners = {};
|
|
this.future = new Promise(r => {
|
|
this.future = new Promise(r => {
|
|
|
|
+ this.resolve = r
|
|
this.socket = new ReconnectingWebSocket(url);
|
|
this.socket = new ReconnectingWebSocket(url);
|
|
openedSocket[url] = this
|
|
openedSocket[url] = this
|
|
this.socket.onmessage = this.messageReceived;
|
|
this.socket.onmessage = this.messageReceived;
|
|
this.socket.onconnecting = () => {
|
|
this.socket.onconnecting = () => {
|
|
|
|
+ this.future = new Promise(resolve => this.resolve = resolve)
|
|
bus.status('message.connectDebugServer')
|
|
bus.status('message.connectDebugServer')
|
|
}
|
|
}
|
|
this.socket.onopen = () => {
|
|
this.socket.onopen = () => {
|
|
bus.status('message.connectDebugServerSuccess')
|
|
bus.status('message.connectDebugServerSuccess')
|
|
bus.$emit('ws_open')
|
|
bus.$emit('ws_open')
|
|
- r()
|
|
|
|
|
|
+ this.resolve()
|
|
}
|
|
}
|
|
this.socket.onclose = () => {
|
|
this.socket.onclose = () => {
|
|
bus.status('message.debugServerClose')
|
|
bus.status('message.debugServerClose')
|
|
@@ -51,11 +53,13 @@ MagicWebSocket.prototype.messageReceived = function (e) {
|
|
bus.$emit('ws_' + msgType, args)
|
|
bus.$emit('ws_' + msgType, args)
|
|
}
|
|
}
|
|
MagicWebSocket.prototype.send = function(msg){
|
|
MagicWebSocket.prototype.send = function(msg){
|
|
- this.future.then(() => this.socket.send(msg))
|
|
|
|
-
|
|
|
|
|
|
+ this.future.then(() => {
|
|
|
|
+ this.socket.send(msg)
|
|
|
|
+ })
|
|
|
|
+
|
|
}
|
|
}
|
|
MagicWebSocket.prototype.close = function () {
|
|
MagicWebSocket.prototype.close = function () {
|
|
this.socket.close()
|
|
this.socket.close()
|
|
}
|
|
}
|
|
|
|
|
|
-export default MagicWebSocket
|
|
|
|
|
|
+export default MagicWebSocket
|