up. 添加worker的admin:worker
This commit is contained in:
parent
cafb7ee07d
commit
3e94fbf4c0
@ -3,7 +3,6 @@
|
||||
namespace app\command\admin;
|
||||
|
||||
|
||||
use app\http\worker\AdminWorkerHandle;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
@ -39,14 +38,19 @@ class Worker extends Command
|
||||
} else if ($mode == 'g') {
|
||||
$argv[] = '-g';
|
||||
}
|
||||
$handle = new AdminWorkerHandle();
|
||||
|
||||
/*
|
||||
* 创建后台ws链接
|
||||
*/
|
||||
$adminWorker = new WmWorker('ws://0.0.0.0:19980');
|
||||
$adminWorker->onMessage = [$handle, 'onMessage'];
|
||||
$adminWorker->onClose = [$handle, 'onClose'];
|
||||
$adminWorker = new WmWorker('websocket://0.0.0.0:19980');
|
||||
$adminWorker->onMessage = function ($connection, $message) {
|
||||
var_dump($message);
|
||||
$this->app->event->trigger('admin.websocket.Open', $connection, $message);
|
||||
};
|
||||
$adminWorker->onClose = function ($connection, $message) {
|
||||
var_dump($message);
|
||||
$this->app->event->trigger('admin.websocket.Close', $connection, $message);
|
||||
};
|
||||
|
||||
WmWorker::runAll();
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace app\http\worker;
|
||||
|
||||
class AdminWorkerHandle
|
||||
{
|
||||
public function onMessage($connection,$data)
|
||||
{
|
||||
$connection->send(json_encode($data));
|
||||
}
|
||||
|
||||
public function onClose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user