Merge pull request #795 from konradkalemba/master
Listen to all events in socket.io connection
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
<script>
|
||||
import { socketioValid } from "~/functions/utils/valid"
|
||||
import io from "socket.io-client"
|
||||
import wildcard from "socketio-wildcard"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -119,6 +120,8 @@ export default {
|
||||
|
||||
try {
|
||||
this.io = new io(this.url)
|
||||
// Add ability to listen to all events
|
||||
wildcard(io.Manager)(this.io)
|
||||
this.io.on("connect", () => {
|
||||
this.connectionState = true
|
||||
this.communication.log = [
|
||||
@@ -133,9 +136,10 @@ export default {
|
||||
icon: "sync",
|
||||
})
|
||||
})
|
||||
this.io.on("message", data => {
|
||||
this.io.on("*", ({ data }) => {
|
||||
const [eventName, message] = data
|
||||
this.communication.log.push({
|
||||
payload: data,
|
||||
payload: `[${eventName}] ${message ? JSON.stringify(message) : ""}`,
|
||||
source: "server",
|
||||
ts: new Date().toLocaleTimeString(),
|
||||
})
|
||||
|
||||
29013
package-lock.json
generated
29013
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -44,6 +44,7 @@
|
||||
"nuxt-i18n": "^6.9.1",
|
||||
"paho-mqtt": "^1.1.0",
|
||||
"socket.io-client": "^2.3.0",
|
||||
"socketio-wildcard": "^2.0.0",
|
||||
"v-tooltip": "^2.0.3",
|
||||
"vue-virtual-scroll-list": "^1.4.7",
|
||||
"vuefire": "^2.2.2",
|
||||
|
||||
Reference in New Issue
Block a user