增加 节点类型选择

This commit is contained in:
iVampireSP.com 2023-02-09 19:08:54 +08:00
parent bf60034518
commit 75a0449ae8
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -84,6 +84,7 @@ public static function hset($key, $value, $data = []): void
* @param string|array $events 事件名称
* @param $callback callable 回调函数,接收一个参数,为事件数据。
* @param $ignore_self bool 是否忽略此节点的消息。
*
* @return void
*/
public static function listen(string|array $events, callable $callback, bool $ignore_self = true): void
@ -143,7 +144,7 @@ public static function hget($key, $hashKey, $default = []): string|array|null
return $value ?: $default;
}
public static function nodes($hide_ip = false): array
public static function nodes($hide_ip = false, $type = 'all'): array
{
$nodes = self::hgetAll('nodes');
@ -156,6 +157,10 @@ public static function nodes($hide_ip = false): array
unset($nodes[$key]['ip']);
}
if ($type !== 'all' && $nodes[$key]['type'] !== $type) {
continue;
}
$append_nodes[] = $nodes[$key];
}