优化代码

main
gzydong 2021-08-20 22:38:46 +08:00
parent baec7984b5
commit cc7fb246e9
6 changed files with 18 additions and 7 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -19,7 +19,7 @@ class TalkModeConstant
*/
const GROUP_CHAT = 2;
public static function getTypes()
public static function getTypes(): array
{
return [
self::PRIVATE_CHAT,