Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

php - 推杆未触发事件不起作用Laravel(Pusher not triggering event is not working Laravel)

I am trying to trigger a pusher event but it's not working.

(我正在尝试触发推送事件,但无法正常工作。)

class SendWaitingForRedirect implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $message;

    public function __construct($message)
    {
        $this->message = $message;
    }

    public function broadcastOn()
    {
        return ['my-channel'];
    }

    public function broadcastAs()
    {
        return 'my-event';
    }
}

and calling the event as

(并将事件称为)

event(new AppEventsSendWaitingForRedirect('hello world'));

I don't know what's wrong.

(我不知道怎么了)

Can you please help?

(你能帮忙吗?)

I checked errors on the pusher.

(我检查了推杆上的错误。)

It is not having any errors.

(它没有任何错误。)

Can you please help.

(你能帮忙吗?)

  ask by Jatin Raikwar translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are not used the proper syntax of channel and event.

(您未使用通道和事件的正确语法。)

The syntax is look like this

(语法看起来像这样)

class SendWaitingForRedirect implements ShouldBroadcast
 {
use Dispatchable, InteractsWithSockets, SerializesModels;

public $message;

public function __construct($message)
{
    $this->message = $message;
}

public function broadcastOn()
{
     return new Channel('my-channel');//Use the different type of channel as you want

}

public function broadcastAs()
{
    return $this->message; //Return data as you want
}
}

Hope it helps.

(希望能帮助到你。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...