This commit is contained in:
2026-02-18 17:54:07 +08:00
parent 378b9bd71f
commit e679a9402f
11 changed files with 739 additions and 5 deletions

View File

@@ -19,7 +19,24 @@ class WebSocketService
*/
public function getServer(): ?Server
{
return app('swoole.server');
// Check if Laravel-S is running
if (!class_exists('Hhxsv5\LaravelS\Illuminate\Laravel') || !defined('IN_LARAVELS')) {
return null;
}
try {
// Try to get the Swoole server from the Laravel-S container
$laravelS = \Hhxsv5\LaravelS\Illuminate\Laravel::getInstance();
if ($laravelS && $laravelS->getSwooleServer()) {
return $laravelS->getSwooleServer();
}
} catch (\Exception $e) {
Log::warning('Failed to get Swoole server instance', [
'error' => $e->getMessage()
]);
}
return null;
}
/**