probil/vue-socket.io-extended

Problem with event names marked with "-"

tachibana-shin opened this issue · 2 comments

hi on the server I have an event named "SERVER__newAnswer-comment" how can I listen for the event on the client

  1. On Component
new Vue({
  sockets: {
    connect() {
      console.log('socket connected')
    },
    'SERVER__newAnswer-comment'(val) {
      console.log('this method was fired by the socket server. eg: io.emit("customEmit", data)')
    }
  },
})
  1. On Vuex Store
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

const messages = {
  mutations: {
    'SOCKET_SERVER__NEWANSWER-COMMENT'(state, message) {
      // your implementation here
    }
  },
  actions: {
    socket_serverNewAnswerComment() {
      // your implementation here
    }
  }
};

@NguyenThanh1995 Let me know if it helped