WokerTask/app/common/service/workerim/Events.php

29 lines
707 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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
{
}
}