checkwebsocket function
This commit is contained in:
parent
270712e07d
commit
4ad7d915e5
3 changed files with 20 additions and 18 deletions
|
|
@ -38,6 +38,7 @@
|
||||||
class="full-width"
|
class="full-width"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
|
@click="checkWebSocket"
|
||||||
>
|
>
|
||||||
<template>
|
<template>
|
||||||
<q-btn
|
<q-btn
|
||||||
|
|
|
||||||
|
|
@ -1280,6 +1280,15 @@
|
||||||
|
|
||||||
this.clearMessage()
|
this.clearMessage()
|
||||||
},
|
},
|
||||||
|
checkWebSocket() {
|
||||||
|
if (!this.ws) return
|
||||||
|
if (this.ws.readyState === WebSocket.CLOSED) {
|
||||||
|
console.log('WebSocket CLOSED: Reopening')
|
||||||
|
this.ws = new WebSocket(
|
||||||
|
ws_scheme + location.host + '/shop/ws/' + this.customerKey
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
chatRoom(id) {
|
chatRoom(id) {
|
||||||
this.startChat(id)
|
this.startChat(id)
|
||||||
this.orderMessages = {}
|
this.orderMessages = {}
|
||||||
|
|
@ -1309,15 +1318,6 @@
|
||||||
}
|
}
|
||||||
ws = new WebSocket(ws_scheme + location.host + '/shop/ws/' + room_name)
|
ws = new WebSocket(ws_scheme + location.host + '/shop/ws/' + room_name)
|
||||||
|
|
||||||
function checkWebSocket(event) {
|
|
||||||
if (ws.readyState === WebSocket.CLOSED) {
|
|
||||||
console.log('WebSocket CLOSED: Reopening')
|
|
||||||
ws = new WebSocket(
|
|
||||||
ws_scheme + location.host + '/shop/ws/' + room_name
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ws.onmessage = async event => {
|
ws.onmessage = async event => {
|
||||||
let event_data = JSON.parse(event.data)
|
let event_data = JSON.parse(event.data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
class="full-width"
|
class="full-width"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
|
@click="checkWebSocket"
|
||||||
>
|
>
|
||||||
<template>
|
<template>
|
||||||
<q-btn
|
<q-btn
|
||||||
|
|
@ -387,6 +388,15 @@
|
||||||
await this.getMessages(this.selectedOrder)
|
await this.getMessages(this.selectedOrder)
|
||||||
this.startChat(this.selectedOrder)
|
this.startChat(this.selectedOrder)
|
||||||
},
|
},
|
||||||
|
checkWebSocket() {
|
||||||
|
if (!this.ws) return
|
||||||
|
if (this.ws.readyState === WebSocket.CLOSED) {
|
||||||
|
console.log('WebSocket CLOSED: Reopening')
|
||||||
|
this.ws = new WebSocket(
|
||||||
|
ws_scheme + location.host + '/shop/ws/' + this.selectedOrder
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
startChat(room_name) {
|
startChat(room_name) {
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
this.ws.close()
|
this.ws.close()
|
||||||
|
|
@ -398,15 +408,6 @@
|
||||||
}
|
}
|
||||||
ws = new WebSocket(ws_scheme + location.host + '/shop/ws/' + room_name)
|
ws = new WebSocket(ws_scheme + location.host + '/shop/ws/' + room_name)
|
||||||
|
|
||||||
function checkWebSocket(event) {
|
|
||||||
if (ws.readyState === WebSocket.CLOSED) {
|
|
||||||
console.log('WebSocket CLOSED: Reopening')
|
|
||||||
ws = new WebSocket(
|
|
||||||
ws_scheme + location.host + '/shop/ws/' + room_name
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ws.onmessage = event => {
|
ws.onmessage = event => {
|
||||||
let event_data = JSON.parse(event.data)
|
let event_data = JSON.parse(event.data)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue