2017-07-24 152 views
0

我想要做一些事情来运行使用自定义控制台命令发送laravel事件的测试。使用控制台命令发送广播事件到推送服务器

Artisan::command('event:send', function() { 
     event(new \MarketPlex\Events\ClientAction([ 'id' => 4, 'name' => 'MyEvent' ])); 
     $this->comment(Inspiring::quote()); 
})->describe('throws an event'); 

我的事件,

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

/** 
* The name of the queue on which to place the event. 
* 
* @var string 
*/ 
public $broadcastQueue = 'client-action'; 

/** 
* Information about the request created by user action (Must be public, otherwise laravel     can't serialize). 
* 
* @var string 
*/ 
public $request; 

/** 
* Create a new event instance. 
* 
* @return void 
*/ 
    public function __construct(array $request) 
    { 
     // 
     $this->request = $request; 
} 
} 

它不发送任何内容推服务器。我检查了所有的钥匙。

php artisan event:send 

回答

0

事件是否正常工作?

如果不是,您使用哪种版本的Pusher库?如果您使用3.0,请尝试使用2.x版本。

+0

〜2.0。但如果我使用Pusher的trigger(),它会将消息发送到服务器。但如果我使用event()辅助方法,它不会发送。 – wOwhOw

+0

我正在运行laravel 5.4并使用Pusher服务器〜2.6。还是一样。 – wOwhOw

+0

嗨,没有看到所有的代码很难帮助 - 所以我会推荐阅读本教程。如果你不能得到这个工作,让我知道。 https://blog.pusher.com/writing-realtime-apps-with-laravel-5-and-pusher/ – kn100