From cc7fb246e99a2d6fe9abb18c4a76e93162129db0 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Fri, 20 Aug 2021 22:38:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Cache/GroupCache.php | 2 +- app/Cache/LastMessage.php | 2 +- app/Cache/SocketRoom.php | 12 ++++++++++-- app/Cache/SocketUserBindFds.php | 3 ++- app/Cache/UnreadTalkCache.php | 4 +++- app/Constants/TalkModeConstant.php | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/Cache/GroupCache.php b/app/Cache/GroupCache.php index 6f08ee7..cba98f6 100644 --- a/app/Cache/GroupCache.php +++ b/app/Cache/GroupCache.php @@ -19,7 +19,7 @@ class GroupCache extends StringRedis * @param int $group_id * @return array */ - public function updateCache(int $group_id) + public function updateCache(int $group_id): array { $group = Group::where('id', $group_id)->first(); diff --git a/app/Cache/LastMessage.php b/app/Cache/LastMessage.php index 44b28fc..336b5fa 100644 --- a/app/Cache/LastMessage.php +++ b/app/Cache/LastMessage.php @@ -49,7 +49,7 @@ class LastMessage extends HashRedis * * @return string */ - public function flag(int $type, int $sender, int $receive) + public function flag(int $type, int $sender, int $receive): string { // 群聊信息(非私信),发送者ID重置为零 if ($type == 2) $sender = 0; diff --git a/app/Cache/SocketRoom.php b/app/Cache/SocketRoom.php index b9e888d..cf3b638 100644 --- a/app/Cache/SocketRoom.php +++ b/app/Cache/SocketRoom.php @@ -50,7 +50,15 @@ class SocketRoom extends SetGroupRedis return $this->add($room, ...$member); } - public function delRoomMember($room, string ...$member) + /** + * + * 删除房间成员 + * + * @param string $room 房间名 + * @param string ...$member 用户ID + * @return int + */ + public function delRoomMember(string $room, string ...$member): int { return $this->rem($room, ...$member); } @@ -61,7 +69,7 @@ class SocketRoom extends SetGroupRedis * @param string|int $room 房间名 * @return int */ - public function delRoom($room) + public function delRoom($room): int { return $this->delete($room); } diff --git a/app/Cache/SocketUserBindFds.php b/app/Cache/SocketUserBindFds.php index a6acf89..ba5b22d 100644 --- a/app/Cache/SocketUserBindFds.php +++ b/app/Cache/SocketUserBindFds.php @@ -29,10 +29,11 @@ class SocketUserBindFds extends SetGroupRedis /** * @param int $fd 客户端ID + * @param int $user_id * @param string $run_id 服务运行ID(默认当前服务ID) * @return int */ - public function unBind(int $fd, int $user_id, $run_id = SERVER_RUN_ID) + public function unBind(int $fd, int $user_id, $run_id = SERVER_RUN_ID): int { return $this->rem($this->filter([$run_id, $user_id]), $fd); } diff --git a/app/Cache/UnreadTalkCache.php b/app/Cache/UnreadTalkCache.php index 80e6cc6..e8539a5 100644 --- a/app/Cache/UnreadTalkCache.php +++ b/app/Cache/UnreadTalkCache.php @@ -53,9 +53,11 @@ class UnreadTalkCache extends HashRedis /** * 获取 Hash 成员 key * + * @param int $sender + * @param int $receive * @return string */ - public function flag(int $sender, int $receive) + public function flag(int $sender, int $receive): string { return sprintf("%s_%s", $sender, $receive); } diff --git a/app/Constants/TalkModeConstant.php b/app/Constants/TalkModeConstant.php index 4e402b9..f1c75c1 100644 --- a/app/Constants/TalkModeConstant.php +++ b/app/Constants/TalkModeConstant.php @@ -19,7 +19,7 @@ class TalkModeConstant */ const GROUP_CHAT = 2; - public static function getTypes() + public static function getTypes(): array { return [ self::PRIVATE_CHAT,