*/ namespace App\Listener; use App\Event\LogEvent; use App\Model\Online; use App\Utils\Ip; use Hyperf\Event\Annotation\Listener; use Hyperf\Event\Contract\ListenerInterface; #[Listener] class LogHandleListener implements ListenerInterface { public function listen(): array { return [ LogEvent::class, ]; } public function process(object $event): void { Online::insert([ 'session_id' => $event->data['uuid'], 'account_type' => $event->data['account_type'], 'belong_id' => $event->data['belong_id'], 'account_id' => $event->data['account_id'], 'username' => $event->data['username'], 'online_time' => date("Y-m-d H:i:s"), 'ua' => Ip::ua(), 'ip' => Ip::ip() ]); } }