在使用没有错误消息的私有通道时无法从推送器获得响应

使用公共频道时,我确实收到了回复,但是当我将其更改为私人频道时 channels.php文件返回true,我没有得到任何响应,而且从推送者的角度来看,很明显消息已经到达但是laravel echo没有得到响应之后</ p>
</ div>

展开原文

原文

When using public channel, I do get the responses but the moment I change this to a private channel with the check in channels.php file returning true, I get no response and from pusher's side, it is clear that the message is getting there but laravel echo is not getting the response after that

douhua1890
douhua1890 你如何注册私人频道?请显示一些代码
一年多之前 回复

1个回答

Hope my code will help you Configure events

public function broadcastOn()
    {
        return new PrivateChannel('Chat.'. $this->chat->user_id.'.'.$this->chat->friend_id);
    }

add channel

 Broadcast::channel('Chat.{user_id}.{friend_id}', function ($user, 
  $user_id,$friend_id) {
    return $user->id == $friend_id;
 });

get data from this channel

axios.post('/chat/getchat/'+friendId).then((response)=>{
        this.chats = response.data;
      });
      Echo.private('Chat.'+friendId+'.'+userId)
      .listen('BroadcastChat',(e)=>{
        this.chats.push(e.chat);
      });
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐