diff --git a/app/Controller/Api/V1/GroupController.php b/app/Controller/Api/V1/GroupController.php index e960921..7d22cf7 100644 --- a/app/Controller/Api/V1/GroupController.php +++ b/app/Controller/Api/V1/GroupController.php @@ -105,6 +105,8 @@ class GroupController extends CController return $this->response->fail('群组解散失败...'); } + $this->socketRoomService->delRoom($params['group_id']); + // ... 推送群消息 return $this->response->success([], '群组解散成功...'); diff --git a/app/Controller/WebSocketController.php b/app/Controller/WebSocketController.php index 4f17feb..34666b6 100644 --- a/app/Controller/WebSocketController.php +++ b/app/Controller/WebSocketController.php @@ -129,7 +129,7 @@ class WebSocketController implements OnMessageInterface, OnOpenInterface, OnClos { $user_id = $this->socketFDService->findFdUserId($fd); - // stdout_log()->notice("客户端FD:{$fd} 已关闭连接 ,用户ID为【{$user_id}】,关闭时间:" . date('Y-m-d H:i:s')); + stdout_log()->notice("客户端FD:{$fd} 已关闭连接 ,用户ID为【{$user_id}】,关闭时间:" . date('Y-m-d H:i:s')); // 解除fd关系 $this->socketFDService->removeRelation($fd); diff --git a/app/Service/SocketRoomService.php b/app/Service/SocketRoomService.php index 5c1fdde..00270a2 100644 --- a/app/Service/SocketRoomService.php +++ b/app/Service/SocketRoomService.php @@ -51,4 +51,15 @@ class SocketRoomService { return redis()->sRem($this->getRoomName($room), $members); } + + /** + * 删除房间 + * + * @param string|int $room 房间名 + * @return int + */ + public function delRoom($room) + { + return redis()->del($this->getRoomName($room)); + } } diff --git a/config/autoload/server.php b/config/autoload/server.php index 1e4513f..3248d6a 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -46,7 +46,7 @@ return [ ], 'settings' => [ 'enable_coroutine' => true, - 'worker_num' => 1, + 'worker_num' => swoole_cpu_num(), 'pid_file' => BASE_PATH . '/runtime/hyperf.pid', 'open_tcp_nodelay' => true, 'max_coroutine' => 100000,