webman icon indicating copy to clipboard operation
webman copied to clipboard

How to alternative sleep function in API webman

Open haidarvm opened this issue 2 years ago • 1 comments

I create API applications for alarm notification Who to add sleep() function without sleep the webman process ?

haidarvm avatar Feb 01 '23 06:02 haidarvm

composer require workerman/webman-framework ^1.5.0 && composer require workerman/workerman 5.0.0-beta.1 && composer require revolt/event-loop

Usage

<?php
namespace app\controller;

use support\Request;
use Workerman\Timer;

class IndexController
{
    public function index(Request $request)
    {
        Timer::sleep(1); // <=== Here is nonblocking sleep 
        return response('hello webman');
    }
}

walkor avatar Feb 01 '23 08:02 walkor