【发布时间】:2019-03-27 21:15:16
【问题描述】:
我正在制作一个使用 Pusher 和 Laravel 的小型约会应用程序。我使用一个名为NewMessage 的事件并在频道msg.{userId} 上收听。聆听有效,但广播事件无效。但它适用于生产。
我的代码如下:
NewMessage.php
public function __construct(Message $message, $toUserId, $conversation)
{
//
$this->message = $message;
$this->toUserId = $toUserId;
$this->conversation = $conversation;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('msg.'.$this->toUserId);
}
public function broadcastAs()
{
return 'NewMessage';
}
ConversationController.php
event(new NewMessage($message, $toUserId, $conversation));
【问题讨论】:
-
您在生产中是否有 SSL 连接? :)
-
是的,它在 heroku 上