mirror of
https://gitlab.com/RemixDev/deemix-webui.git
synced 2024-12-28 02:16:11 +00:00
Removed socket.io and implemented WebSockets
This commit is contained in:
parent
55125684cb
commit
509f940afd
|
@ -17,7 +17,6 @@
|
|||
"@vue/composition-api": "^1.0.0-beta.21",
|
||||
"flag-icon-css": "^3.5.0",
|
||||
"lodash-es": "^4.17.15",
|
||||
"socket.io-client": "^3.1.0",
|
||||
"svg-country-flags": "^1.2.9",
|
||||
"toastify-js": "^1.9.3",
|
||||
"vue": "^2.6.12",
|
||||
|
|
2409
public/js/bundle.js
2409
public/js/bundle.js
File diff suppressed because one or more lines are too long
|
@ -28,10 +28,6 @@ export default {
|
|||
find: 'vue',
|
||||
replacement: 'vue/dist/vue.esm'
|
||||
},
|
||||
{
|
||||
find: 'socket.io-client',
|
||||
replacement: 'socket.io-client/dist/socket.io.min'
|
||||
},
|
||||
{
|
||||
find: '@',
|
||||
replacement: __dirname + '/src'
|
||||
|
|
|
@ -69,7 +69,8 @@ export default {
|
|||
// ConfirmModal
|
||||
},
|
||||
mounted() {
|
||||
socket.on('connect', () => {
|
||||
socket.addEventListener('open', (event) => {
|
||||
console.log("Connected to WebSocket")
|
||||
this.isSocketConnected = true
|
||||
})
|
||||
}
|
||||
|
|
|
@ -7,8 +7,5 @@
|
|||
"@components/*": ["./components/*"]
|
||||
}
|
||||
},
|
||||
"typeAcquisition": {
|
||||
"include": ["socket.io-client"]
|
||||
},
|
||||
"exclude": ["assets/**/*", "styles/**/*"]
|
||||
}
|
||||
|
|
|
@ -1,8 +1,25 @@
|
|||
import store from '@/store'
|
||||
import io from 'socket.io-client'
|
||||
|
||||
export const socket = io.connect('/')
|
||||
class CustomSocket extends WebSocket {
|
||||
constructor(args) {
|
||||
super(args)
|
||||
console.log(args)
|
||||
}
|
||||
|
||||
socket.on('init_update', data => {
|
||||
store.dispatch('setAppInfo', data)
|
||||
})
|
||||
emit(key, data) {
|
||||
console.log("emit:", key, data)
|
||||
console.log(this.readyState)
|
||||
if (this.readyState != WebSocket.OPEN) return false
|
||||
this.send(JSON.stringify({key:key, data:data}))
|
||||
}
|
||||
|
||||
on(key, callback) {
|
||||
this.addEventListener('message', function(event){
|
||||
console.log(event.data)
|
||||
let data = JSON.parse(event.data)
|
||||
if (data.key == key) callback(data.data)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const socket = new CustomSocket('ws://' + location.host + '/')
|
||||
|
|
Loading…
Reference in a new issue