Gateway::leaveGroup
說明:
void Gateway::leaveGroup(string $client_id, mixed $group);
將client_id從某個組中刪除,不再接收該分組廣播(Gateway::sendToGroup
)發(fā)送的數(shù)據(jù)。
注意:當(dāng)client_id下線(連接斷開)時,client_id會自動從它所屬的各個分組中刪除,也就是說無需在onClose回調(diào)中調(diào)用Gateway::leaveGroup
參數(shù)
$client_id
客戶端的client_id
$group
只能是數(shù)字或者字符串。
返回值
無返回值
范例
use \GatewayWorker\Lib\Gateway;
class Events
{
...
public static function onMessage($client_id, $message)
{
// $message = '{"type":"leave","group":"xxxxx"}'
$req_data = json_decode($message, true);
Gateway::leaveGroup($client_id, $req_data['group']);
}
...
}