新增文件实时协同人员

This commit is contained in:
kuaifan
2021-07-06 19:13:41 +08:00
parent e2c6812b08
commit adea662eeb
10 changed files with 134 additions and 19 deletions

View File

@@ -132,6 +132,22 @@ class WebSocketService implements WebSocketHandlerInterface
$item->readSuccess($userid);
});
return;
/**
* 访问状态
*/
case 'path':
$row = WebSocket::whereFd($frame->fd)->first();
if ($row) {
$pathNew = $data['path'];
$pathOld = $row->path;
$row->path = $pathNew;
$row->save();
if (preg_match("/^file\/content\/\d+$/", $pathNew) || preg_match("/^file\/content\/\d+$/", $pathOld)) {
$this->pushPath($pathNew);
}
}
return;
}
//
if ($msgId) {
@@ -197,4 +213,28 @@ class WebSocketService implements WebSocketHandlerInterface
{
return intval(WebSocket::whereFd($fd)->value('userid'));
}
/**
* 发送给相同访问状态的会员
* @param $path
*/
private function pushPath($path)
{
$array = WebSocket::wherePath($path)->pluck('userid')->toArray();
if ($array) {
$userids = array_values(array_filter(array_unique($array)));
$params = [
'userid' => $userids,
'msg' => [
'type' => 'path',
'data' => [
'path' => $path,
'userids' => $userids
],
]
];
$task = new PushTask($params, false);
Task::deliver($task);
}
}
}