Gateway::sendToClient

    • $client_id
    • $send_data
    1. use \GatewayWorker\Lib\Gateway;
    2. {
    3. ...
    4. public static function onMessage($client_id, $message)
    5. {
    6. // $message = '{"type":"say_to_one","to_client_id":100,"content":"hello"}'
    7. $req_data = json_decode($message, true);
    8. if($req_data['type'] == 'say_to_one')
    9. // 转发消息给对应的客户端
    10. Gateway::sendToClient($req_data['to_client_id'], $req_data['content']);
    11. }
    12. }