2025-08-22 18:16:13 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace plugin\webman\gateway;
|
|
|
|
|
|
|
|
|
|
|
|
use app\common\utils\WsEvents;
|
|
|
|
|
|
use GatewayWorker\Lib\Gateway;
|
|
|
|
|
|
|
|
|
|
|
|
class Events
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
protected static $wsEvents;
|
|
|
|
|
|
|
|
|
|
|
|
public static function onWorkerStart($worker)
|
|
|
|
|
|
{
|
|
|
|
|
|
self::$wsEvents = new WsEvents();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function onConnect($client_id)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 仅 TCP 连接,不一定有 WebSocket 握手
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function onWebSocketConnect($client_id, $data)
|
|
|
|
|
|
{
|
|
|
|
|
|
self::$wsEvents->auth($client_id, $data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function onMessage($client_id, $message)
|
|
|
|
|
|
{
|
|
|
|
|
|
self::$wsEvents->message($client_id, $message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function onClose($client_id)
|
|
|
|
|
|
{
|
2025-10-11 08:41:11 +00:00
|
|
|
|
self::$wsEvents->logout($client_id);
|
2025-08-22 18:16:13 +08:00
|
|
|
|
var_dump('关闭客户端ID:'.$client_id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|