0
나는 이벤트 방송을 위해 laravel 5.4와 푸셔를 사용하고있다. 개인 채널 "chatroom"을 만듭니다. 가져 오기 오류 Laravel Echo.join working only Echo.channel and Echo.private not working
나는 이벤트 방송을 위해 laravel 5.4와 푸셔를 사용하고있다. 개인 채널 "chatroom"을 만듭니다. 가져 오기 오류 Laravel Echo.join working only Echo.channel and Echo.private not working
다음
Echo.join('chatroom') /// Work Well
.listen('MessagePosted', (e) => {
this.messages.push({
body: e.message.body
});
});
그러나 이것은 채널 및 개인 작동하지 않습니다 ...
Echo.channel('chatroom') OR
Echo.private('chatroom') //// Not Working
당신은 mounted()
방법 안에이를 넣을 필요가있다. 오류가 당신이 개인 채팅을 할 경우 .here
가 routes/channels.php
에서 다음
mounted(){
Echo.private('chat')
.listen('ChatEvent', (e) => {
console.log(e);
});
//Make function for joining and leaving for any users
Echo.join('chat')
.here((users) => {
console.log(users)
})
.joining((user) => {
console.log(user.name)
})
.leaving((user) => {
console.log(user.name)
});
}
기능하지 않고 있다고 대답 때문에, 당신은 정의했습니다/이런 chat
라는 이름의 채널 등록 -
Broadcast::channel('chat', function($user){
return ['name' => $user->name]; //Return data as your need
});
희망을, 누군가를 도울 것입니다.