up. ws update.
This commit is contained in:
parent
98cb8ee0aa
commit
ee99f4e7d9
@ -3,6 +3,7 @@
|
|||||||
namespace app\command\admin;
|
namespace app\command\admin;
|
||||||
|
|
||||||
|
|
||||||
|
use app\service\admin\LoginService;
|
||||||
use think\console\Command;
|
use think\console\Command;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\input\Argument;
|
use think\console\input\Argument;
|
||||||
@ -46,6 +47,23 @@ class Worker extends Command
|
|||||||
$adminWorker->onMessage = function ($connection, $message) {
|
$adminWorker->onMessage = function ($connection, $message) {
|
||||||
var_dump($message);
|
var_dump($message);
|
||||||
$this->app->event->trigger('admin.websocket.Open', $connection, $message);
|
$this->app->event->trigger('admin.websocket.Open', $connection, $message);
|
||||||
|
$messageJson = json_decode($message, true);
|
||||||
|
if($messageJson) {
|
||||||
|
if($messageJson['event'] == 'bind_connect_id') {
|
||||||
|
$authorization = $messageJson['data']['token'] ?? '';
|
||||||
|
$authorization = str_replace('Bearer ', '', $authorization);
|
||||||
|
$loginSrv = new LoginService();
|
||||||
|
$auth = $loginSrv->checkUserAccessToken($authorization);
|
||||||
|
var_dump("当前用户: ".$auth->userId);
|
||||||
|
$connection->userId = $auth->userId;
|
||||||
|
$connection->send(json_encode(['event'=>'bind_connect_id_success','userId'=>$auth->userId]));
|
||||||
|
}
|
||||||
|
if ($messageJson['event'] == 'lock_client_screen') {
|
||||||
|
if($connection->userId) {
|
||||||
|
var_dump("锁定客户端/通知全部ws触发锁定操作");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
$adminWorker->onClose = function ($connection) {
|
$adminWorker->onClose = function ($connection) {
|
||||||
$this->app->event->trigger('admin.websocket.Close', $connection);
|
$this->app->event->trigger('admin.websocket.Close', $connection);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user