AppserverIo\Appserver\Core\ApplicationServer::init PHP Method

init() public method

The runlevel to switch to.
public init ( React\Socket\ConnectionInterface $conn = null, integer $runlevel = ApplicationServerInterface::FULL ) : void
$conn React\Socket\ConnectionInterface The connection resource
$runlevel integer The new runlevel to switch to
return void
    public function init(ConnectionInterface $conn = null, $runlevel = ApplicationServerInterface::FULL)
    {
        // switch to the new runlevel
        $this->synchronized(function ($self, $newRunlevel) {
            // wait till the previous commands has been finished
            while ($self->locked === true) {
                sleep(1);
            }
            // set the command name
            $self->command = InitCommand::COMMAND;
            // lock process
            $self->locked = true;
            $self->params = $newRunlevel;
            // notify the AS to execute the command
            $self->notify();
        }, $this, $runlevel);
    }