MetinSeylan / Vue-Socket.io

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

Update query param for socket.io reconnect #343

Closed LegendWojciechPolowniak closed 1 year ago

LegendWojciechPolowniak commented 1 year ago

Hello, thank you for porting the package to Vue3.

Once the socket is connected, we get access to this.$socket object within the component, but there's no way to update the query parameter (for example to mark client reconnection).

In socket.io itself you can do socket.socket.options.query = 'whatever=whatever; to update the query, which will be used when the connect method is called the next time.

Could we introduce a way to update the query params of socket connection after the initialisation?

LegendWojciechPolowniak commented 1 year ago

Setting both: this.$socket.io.uri = 'https://socket.example.com/?token=' + data.socket_auth_token; this.$socket.io.opts.query = 'token=' + data.socket_auth_token;

And reconnecting, solves this.