Closed lord-zeus closed 5 years ago
Try the new version
it works when I use it this way
axios.defaults.headers.common['X-Socket-Id'] = Echo.socketId();
when the X-Socket-Id is being place and I navigate out of that component and back into the component the it start receiving the broadcast to others.
each time I get into that page I leave that channel before re-entering it back any ideas ?
Echo.leave('channel-name');
almost like the channel is not being left
Hello, you can share more information about your case, such as the NS version and the plugin, at which moment you launch the events of join
andleave
, greetings.
lets say I have two component Home & Chat
I leave from the home to the chat where the join and the leave are
mounted(){
const Echo = new TnsEcho({
host: url,
authEndpoint: '/broadcasting/auth',
broadcaster: 'socket.io',
debug: false,
auth: {
headers: {
Authorization: 'Bearer ' + token
}
},
});
setTimeout(() => {
Echo.socketId();
axios.defaults.headers.common['X-Socket-Id'] = Echo.socketId();
}, 1000);//half second for get socket id, only socket.io
Echo.leave('chat_id');
Echo.private('chat_id')
.listen('ChatEvent', (chat) => {
....
console.log(chat);
`});`
},
but it does not leave the channel each time it enter the chat component it just creates a new channel with a new socket id there by causing the application to listen to its own broadcast()->toOthers
You're using the versión 1.0.3?
You're using the versión 1.0.3?
yes I thought it was the problem so I updated to it but still has same problem
try this
export default {
data() {
return {
echo: null,
channel: ''
}
},
mounted() {
this.channel = 'MiChannel';
this.echo = new Echo(options);
this.echo.join(this.channel)
.here((users) => {
console.log(users);
})
.joining((user) => {
})
.leaving((user) => {
})
.listen('Event', (e) => {
});
},
destroyed() {
this.echo.leave(this.channel);
}
}
I have same problem, i can't get socketId. Seem, this.echo.socketId() not working.
I catch error JS: [TypeError: Cannot read property 'id' of undefined]
In the connector socketio-connector.js
, this.socket.socket.id()
is undefined.
It should be this.socket.android.id()
or this.socket.ios.id()
depending on the platform
I work on the solution these days
Any new information about this issue?
Ready uploading
When broadcasting to others you end up still receiving the the broadcast any help on this ?