39 lines
796 B
PHP
39 lines
796 B
PHP
<?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)
|
||
{
|
||
self::$wsEvents->logout($client_id);
|
||
// var_dump('关闭客户端ID:'.$client_id);
|
||
}
|
||
|
||
} |