get data of on event connection in vue-socket-io

Viewed 376

i want to get data in on connect to socket io and i wrote this config in main.js file based on documentation for https://www.npmjs.com/package/vue-socket.io

import VueSocketIO from 'vue-socket.io'
Vue.use(new VueSocketIO({
    debug: true,
    connection: 'http://es.mappserver.com',
    vuex: {
        store,
        actionPrefix: 'SOCKET_',
        mutationPrefix: 'SOCKET_'
    },
    options: {} //Optional options
}))

new Vue({
    sockets: {
        connect: function (data) {
            console.log('socket connected')
        },
        customEmit: function (data) {
            console.log('this method was fired by the socket server. eg: io.emit("customEmit", data)')
        }
    },
  router,
  store,
  render: h => h(App),
}).$mount('#app')

and this is my code snippet in my component:

this.$socket.on('currency-channel', (data) => {
     console.log(data);
});

i get socket connected message in my console bu i gave nothing for get data of it nor error how can i fix this issue? i have no answer in document

0 Answers
Related