Gateway::ungroup
說明:
void Gateway::ungroup(mixed $group);
(要求Gateway版本>=3.0.9)
如何查看Gateway版本
取消分組,或者說解散分組。
取消分組后所有屬于這個(gè)分組的用戶的連接將被移出分組,此分組將不再存在,除非再次調(diào)用Gateway::joinGroup($client_id, $group)
將連接加入分組。
注意:
1、調(diào)用Gateway::ungroup($group)
相當(dāng)于以下代碼,
$client_id_list = Gateway::getClientIdListByGroup($group);
foreach($client_id_list as $client_id) {
Gateway::leaveGroup($client_id, $group);
}
區(qū)別是Gateway::ungroup($group)
性能要好很多。
2、調(diào)用Gateway::ungroup($group)
后,仍然可以調(diào)用Gateway::joinGroup($client_id, $group)
將某個(gè)連接加入這個(gè)分組。
參數(shù)
$group
只能是數(shù)字或者字符串。
返回值
無返回值
范例
use \GatewayWorker\Lib\Gateway;
class Events
{
...
public static function onMessage($client_id, $message)
{
// $message = '{"type":"ungroup","group":"xxxxx"}'
$req_data = json_decode($message, true);
Gateway::ungroup($req_data['group']);
}
...
}