laravel-websockets/tests/Websocket/Fixtures/ChildCrash/ChildCrashController.php

44 lines
908 B
PHP

<?php
declare(strict_types=1);
namespace BlaxSoftware\LaravelWebSockets\Test\Websocket\Fixtures\ChildCrash;
use BlaxSoftware\LaravelWebSockets\Attributes\Websocket;
/**
* Handlers for HandlerChildLifecycleTest. They run in real forked message
* children. Events: child-crash.ok, child-crash.killed, child-crash.hold.
*/
class ChildCrashController
{
#[Websocket]
public function ok(): array
{
return ['ok' => true];
}
/**
* Dies without replying, like a child taken by the kernel OOM killer.
*/
#[Websocket]
public function killed(): array
{
posix_kill(getmypid(), SIGKILL);
sleep(5);
return ['unreachable' => true];
}
/**
* Blocks like a long-running engine until the server stops it.
*/
#[Websocket]
public function hold(): array
{
sleep(10);
return ['held' => true];
}
}