29 lines
707 B
PHP
29 lines
707 B
PHP
<?php
|
||
namespace app\common\service\workerim;
|
||
|
||
use GatewayClient\Gateway;
|
||
|
||
/**
|
||
* 主逻辑
|
||
* 主要是处理 onConnect onMessage onClose 三个方法
|
||
* onConnect 和 onClose 如果不需要可以不用实现并删除
|
||
*/
|
||
class Events
|
||
{
|
||
|
||
// 当有客户端连接时,将client_id返回,让mvc框架判断当前uid并执行绑定
|
||
public static function onConnect($client_id): void
|
||
{
|
||
Gateway::sendToClient($client_id, json_encode(array(
|
||
'type' => 'init',
|
||
'client_id' => $client_id
|
||
)));
|
||
}
|
||
|
||
// GatewayWorker建议不做任何业务逻辑,onMessage留空即可
|
||
public static function onMessage($client_id, $message): void
|
||
{
|
||
|
||
}
|
||
}
|