国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

Gateway::joinGroup

說(shuō)明:

void Gateway::joinGroup(string $client_id, mixed $group);

將client_id加入某個(gè)組,以便通過(guò)Gateway::sendToGroup發(fā)送數(shù)據(jù)。

可以通過(guò)Gateway::getClientSessionsByGroup($group)獲得該組所有在線成員數(shù)據(jù)。
可以通過(guò)Gateway::getClientCountByGroup($group)獲得該組所有在線連接數(shù)(人數(shù))。

該方法對(duì)于分組發(fā)送數(shù)據(jù)例如房間廣播非常有用。

注意:

1、同一個(gè)client_id可以加入多個(gè)分組,以便接收不同組發(fā)來(lái)的數(shù)據(jù)。

2、當(dāng)client_id下線(連接斷開)后,該client_id會(huì)自動(dòng)從該分組中刪除,開發(fā)者無(wú)需調(diào)用Gateway::leaveGroup。

3、如果對(duì)應(yīng)分組的所有client_id都下線,則對(duì)應(yīng)分組會(huì)被自動(dòng)刪除。

4、目前沒有獲得某個(gè)client_id加入哪些分組的接口,建議client_id加入分組的時(shí)候可以用$_SESSION來(lái)記錄加入的分組,獲取的時(shí)候利用$_SESSION或者Gateway::getSession($client_id)來(lái)獲取。

5、目前沒有獲得所有分組id接口,所有分組可以自行存入數(shù)據(jù)庫(kù)或者其它存儲(chǔ)中。

6、分組數(shù)量無(wú)上限。

參數(shù)

  • $client_id

客戶端的client_id

  • $group

只能是數(shù)字或者字符串。

注意:group不能為空值。例如0,0.0,'0',"0",false,null是非法的group值。

返回值

無(wú)返回值

范例

use \GatewayWorker\Lib\Gateway;
class Events
{
    ...

    public static function onMessage($client_id, $message)
    {
        // $message = '{"type":"join","group":"xxxxx"}'
        $req_data = json_decode($message, true);
        Gateway::joinGroup($client_id, $req_data['group']);
    }

    ...
}
編輯于2024-03-13 17:37:33 完善本頁(yè) +發(fā)起討論
贊助商