refactor: CustomWebsocket
This commit is contained in:
parent
cbf3a5c677
commit
efefa7bbf7
File diff suppressed because one or more lines are too long
@ -1,5 +1,3 @@
|
||||
import store from '@/store'
|
||||
|
||||
let wasEventListenerAdded = false
|
||||
|
||||
class CustomSocket extends WebSocket {
|
||||
@ -8,7 +6,8 @@ class CustomSocket extends WebSocket {
|
||||
}
|
||||
emit(key, data) {
|
||||
if (this.readyState !== WebSocket.OPEN) return false
|
||||
this.send(JSON.stringify({ key: key, data: data }))
|
||||
|
||||
this.send(JSON.stringify({ key, data }))
|
||||
}
|
||||
on(key, cb) {
|
||||
if (!wasEventListenerAdded) {
|
||||
|
Loading…
Reference in New Issue
Block a user