我使用Vinelab/minion插件从我client app ( angularjs )
server ( Laravel 4.2 )
获取通知,我在客户端实施autobahn.js,但是当我实现Vinelab/minion
库时Laravel
并试图通过调用php artisan minion:run
来运行minion,它会给我一个像
[Vinelab\Minion\InvalidProviderException]
Provider Vinelab\Minion\ChatProvider must be an instance of \Vinelab\Minion\Provider
我的目录结构:
app/
config/
packages/
vinelab/
minion/
minion.php
providers/
ChatProvider.php
vendor/
并在app/config/packages/vinelab/minion/minion.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Router Realm
|--------------------------------------------------------------------------
|
| The realm that the router should use.
|
*/
'realm' => 'minion',
/*
|--------------------------------------------------------------------------
| Router Host
|--------------------------------------------------------------------------
|
| The IP or hostname that the router should run under.
|
*/
'host' => '127.0.0.1',
/*
|--------------------------------------------------------------------------
| Router Port
|--------------------------------------------------------------------------
|
| The port that should be used by the router.
|
*/
'port' => 9090,
/*
|--------------------------------------------------------------------------
| Auto-registered Providers
|--------------------------------------------------------------------------
|
| The providers listed here will be automatically registered on the
| session start of the router, in return their role is to register RPCs,
| subscribe and publish to topics and pretty much whatever an Internal Client does.
|
*/
'providers' => [
'ChatProvider'
],
'debug' => true,
];
并在 providers / ChatProvider.php
中<?php
use Vinelab\Minion\Provider;
class ChatProvider extends Provider {
protected $prefix = 'order.';
public function boot()
{
// will be registered to topic: chat.send
$this->register('send', 'sendMessage');
}
public function sendMessage($args, $data)
{
$message = $data->message;
// store message in the database
// tell everyone about it
$this->publish('message', compact('message'));
// response with the status
return true;
}
}
}
我检查了各种名称空间和很多东西,但我无法解决这个问题。
我也在github上发布此问题,但未找到任何答案。
这样做是完美还是其他任何方式?
帮助我,这将得到赞赏。
答案 0 :(得分:0)
这是我的扩展课程。
<?php
namespace Chaospower\Messaging\Provider;
use Vinelab\Minion\Provider;
use Auth;
class ChatProvider extends Provider
{
protected $prefix = 'com.';
public function boot()
{
// will be registered to topic: chat.send
$this->register(Config::get('site.domain').'.message', 'sendMessage');
}
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
public function sendMessage($args, $data)
{
$message = $data->message;
// store message in the database?
// tell everyone about it
$this->publish('message', compact('message'));
// response with the status
return true;
}
}
我认为你在某个地方缺少命名空间。因为错误指向Vinelab \ Minion \ ChatProvider。它必须是namespace \ ChatProvider。
输出应如下所示
vagrant@homestead:~/Code/Laravel$ php artisan minion:run --register="Chaospower\Messaging\Provider\ChatProvider"
▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▀▀═════════════▀▀▄
█═══════════════════█
█═════════════════════█
█═══▄▄▄▄▄▄▄═══▄▄▄▄▄▄▄═══█
█═══█████████═█████████═══█
█══██▀ ▀█████▀ ▀██══█
██████ █▀█ ███ █▀█ ██████
██████ ▀▀▀ ███ ▀▀▀ ██████
█══▀█▄ ▄██ ██▄ ▄█▀══█
█════▀█████▀ ▀█████▀════█
█═════════════════════════█
█═════════════════════════█
█═══════▀▄▄▄▄▄▄▄▄▄▀═══════█
█═════════════════════════█
▐▓▓▌═════════════════════▐▓▓▌
▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█
█══█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█══█
▄█══█▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌█══█▄
█████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ █████
██████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ██████
▀█▀█ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ █▀█▀
▐▓▓▓▓▓▓▌▐▓▓▓▓▓▓▌
▐▓▓▓▓▌ ▐▓▓▓▓▌
▄████▀ ▀████▄
▀▀▀▀ ▀▀▀▀
2015-03-10T08:27:58.5390490 info [Vinelab\Minion\Client 5446] New client created
2015-03-10T08:27:58.5467130 info [Thruway\Transport\PawlTransportProvider 5446] Starting Transport
2015-03-10T08:27:58.7215050 info [Thruway\Transport\PawlTransportProvider 5446] Pawl has connected
2015-03-10T08:27:58.8066330 debug [Thruway\Transport\PawlTransportProvider 5446] Received: [2,837176922,{"authrole":"anonymous","authmethod":"anonymous","roles":{"broker":{"features":{"publisher_identification":true,"publisher_exclusion":true,"pattern_based_subscription":true,"subscription_meta_api":true,"subscriber_blackwhite_listing":true}},"dealer":{"features":{"progressive_call_results":true,"pattern_based_registration":true,"registration_meta_api":true,"shared_registration":true,"caller_identification":true}}},"authid":"RK7RIery7evd71THp_Kzcx3h"}]
2015-03-10T08:27:58.8109340 debug [Vinelab\Minion\Client 5446] Client onMessage: [Thruway\Message\WelcomeMessage]
2015-03-10T08:27:58.8110330 info [Vinelab\Minion\Client 5446] We have been welcomed...
2015-03-10T08:27:58.8292430 debug [Thruway\Transport\PawlTransportProvider 5446] Received: [65,1474724289953122,1308617500]
2015-03-10T08:27:58.8347220 debug [Vinelab\Minion\Client 5446] Client onMessage: [Thruway\Message\RegisteredMessage]
2015-03-10T08:27:58.8350070 info [Thruway\Role\Callee 5446] Setting registration_id for com.leadrm.app.message (0)
2015-03-10T08:27:58.8354950 debug [Thruway\Transport\PawlTransportProvider 5446] Received: [33,2002512864967000,1374387471]
2015-03-10T08:27:58.8401330 debug [Vinelab\Minion\Client 5446] Client onMessage: [Thruway\Message\SubscribedMessage]
2015-03-10T08:28:05.0705930 debug [Thruway\Transport\PawlTransportProvider 5446] Received: [36,1374387471,1952879835,{},["test"]]
2015-03-10T08:28:05.0930590 debug [Vinelab\Minion\Client 5446] Client onMessage: [Thruway\Message\EventMessage]
2015-03-10T08:36:11.6339470 debug [Thruway\Transport\PawlTransportProvider 5446] Received: [36,1374387471,1879215773,{},["test"]]
2015-03-10T08:36:11.6341770 debug [Vinelab\Minion\Client 5446] Client onMessage: [Thruway\Message\EventMessage]
2015-03-10T08:36:18.9851460 debug [Thruway\Transport\PawlTransportProvider 5446] Received: [36,1374387471,851409442,{},["test"]]
2015-03-10T08:36:18.9854340 debug [Vinelab\Minion\Client 5446] Client onMessage: [Thruway\Message\EventMessage]
$this->register
是不同的订阅形式。这是一个远程方法调用程序。
如果您需要订阅$this->subscribe('message','callbackfunction')
,那么它将从高速公路准备onMessage功能。
您可以将提供商设置为远程过程注册人或订阅主题。 session.call sendMessage,当你需要发送消息时。