Bal*_*lie 4 laravel pusher vue.js laravel-echo
我开发了一个仪表板,它通过自定义事件获取实时通知。我想实现的是能够在频道之间切换。我使用 Vue(x) 作为前端。
created() {
this.setTeam(this.$router.currentRoute.name);
this.clearFastlanes();
this.getSprintInfo('getSprintInfo');
window.Echo.channel(this.getTeam)
.listen('.jira.issue', this.jiraIssue)
.listen('.jira.fastlane', this.jiraFastlane);
},
Run Code Online (Sandbox Code Playgroud)
这是我订阅自定义事件的主要组件。唯一的问题是,这个组件也被另一个团队使用。所以我想将我的频道更改为当前团队(离开当前频道并加入新团队的频道)。我真的无法在互联网上找到如何做到这一点。
这是我的连接方式:
window.Echo = new Echo({
broadcaster: 'pusher',
key: '29564c255fe1dae3654b',
cluster: 'eu',
encrypted: true,
});
Run Code Online (Sandbox Code Playgroud)
所以基本上我想问 laravel echo 我当前是否已连接,如果是,请离开频道并连接到新团队。
有没有人知道如何实现这一目标?
小智 5
对于连接:
window.Echo.connector.pusher.connection.bind('connected', () => {
console.log('connected');
});
Run Code Online (Sandbox Code Playgroud)
断开连接:
window.Echo.connector.pusher.connection.bind('disconnected', () => {
console.log('disconnected);
});
Run Code Online (Sandbox Code Playgroud)