MetinSeylan / Vue-Socket.io

😻 Socket.io implementation for Vuejs and Vuex
https://metin.sh
MIT License
3.95k stars 496 forks source link

Vue-Socket.io sockets function no perform #257

Closed gufyapk closed 4 years ago

gufyapk commented 4 years ago

@vue/cli 4.2.3 Vue-Socket.io 3.0.9

I use vue-socket.io 3.0.9 sockets is not normal,use 3.0.7 is ok,why?

pslxx commented 4 years ago

yeah,me too!!!!!!!!!!!!!!!!11111

hrr commented 4 years ago

Same here, just downgraded to 3.0.5 and it worked again

super21z commented 4 years ago

Same for me , i also downgraded to 3.0.7

pvkovalev commented 4 years ago

"... socket.io subscribe is not a function ... " Same here, downgraded to 3.0.7 from 3.0.9

sonoscapeweb commented 4 years ago

+1

ninbert commented 4 years ago

any of the options "this.sockets.subscribe"/"this.$sockets.subscribe","this.$socket.subscribe" not working. result => this.sockets.subscribe is not a function

ghost commented 4 years ago

Vue-Socket.io 3.0.9 sockets is not work

this.sockets.subscribe replaced by this.sockets.listener.subscribe

@ninbert

ninbert commented 4 years ago

@gaoquanbing-ausxin, Great!!!!!

what about 'sockets' property in the vue instance?

sockets: { a() { console.log("something") } }

the console.log wont fire when a() is activated from the server

ghost commented 4 years ago

Because the bug in version 3.0.9, sockets: { a() { console.log("something") } }

does not work, u can do as follow: mounted() { this.sockets.listener.subscribe('a', (data) => { console.log("something") }) }

and the sockets is from vue-socket.io( import from main.js), and follow is my config

import VueSocketio from 'vue-socket.io'

Vue.use(new VueSocketio({ debug: true, connection: socketio('ws://xx.xx.xx.xx:10342', { path: '', autoConnect: false, transports: ['websocket', 'xhr-polling', 'jsonp-polling'] }) }))

@ninbert

ninbert commented 4 years ago

@gaoquanbing-ausxin

and what to do in the state actions /mutations?

before it was

mutations: {

 socketListenerA(){
        console.log("something")
 }

}

princetc commented 4 years ago

I don't know if I'm missing anything but seems connection between server and client can be created but on this version the listener function in the Vue life cycle methods does not seem to work

gufyapk commented 4 years ago

@princetc

Refer to the answers above,There are two options

  1. Downgrade to version 3.0.7
  2. In mounted methods,subscribe function

Can solve the problem.

Waiting for the official new version.

wakaka378 commented 4 years ago

Same for me , i also downgraded to 3.0.7

Can you use it normally after dropping to 3.0.7? My version has always been 3.0.7, it was still usable before, and problems have recently started.

this.sockets.subscribe is not a function

And i found

new Vue({
  sockets:{
    connecting() {
      console.log('正在连接')
    },
    disconnect() {
        console.log("Socket 断开");
    },
    connect_failed() {
        cosnole.log('连接失败')
    },
    connect() {
      console.log('socket connected')
    },
    welcome: data => {
      cosnole.log('welcome', datat)
    }
  },
  router,
  store,
  render: h => h(App)
}).$mount('#app')

All events here are not executed,All subscriptions in sockets are invalid Subscription must be used in the component

this.sockets.listener.subscribe()

Then

Vue-Socket.io: #welcome subscribe, component: undefined