我正在运行Echo服务器和Beyondcode(Pusher)。存在频道完美地工作,并且我为其构建的消息功能也可以正常使用。现在,我尝试让“whisper”同样适用于键入状态,但没有成功。
发送“whisper”:
let channel = Echo.join('chat')
setTimeout( () => {
channel.whisper('typing', {
user: Laravel.user.id,
typing: true
})
}, 300)
请注意:
听小声说:Echo.join('chat')
.listenForWhisper('typing', (e) => {
console.log(e)
});
在我的回声服务器日志中,当我输入消息时:
testapp: connection id 332742863.966987392 received message:
{
"event":"client-typing",
"data":{
"user":2,
"typing":true
},
"channel":"presence-chat"
}
广播通道(路由/频道.php)
Broadcast::channel('chat', function ($user) {
return [
'id' => $user->id,
'name' => $user->name
];
});
连接id 332742863.966987392是第二个用户(不是我输入消息的那个用户)。
但浏览器控制台没有任何显示。