PHPDaemon\Examples\ExampleICMPRequest::init PHP Method

init() public method

Constructor.
public init ( ) : void
return void
    public function init()
    {
        $req = $this;
        $job = $this->job = new \PHPDaemon\Core\ComplexJob(function () use($req) {
            // called when job is done
            $req->wakeup();
            // wake up the request immediately
        });
        $job('pingjob', function ($name, $job) use($req) {
            // registering job named 'pingjob'
            \PHPDaemon\Clients\ICMP\Pool::getInstance()->sendPing('8.8.8.8', function ($latency) use($name, $job) {
                $job->setResult($name, $latency);
            });
        });
        $job();
        // let the fun begin
        $this->sleep(5, true);
        // setting timeout
    }
ExampleICMPRequest