src/Task.php
public static function co(array $tasks): array
    {
        $taskCos = [];
        foreach ($tasks as $task) {
            if (! isset($task['type']) || ! isset($task['name']) || ! isset($task['method']) || ! isset($task['params'])) {
                App::error(sprintf('Task %s format error.', $task['name'] ?? '[UNKNOWN]'));
                continue;
            }

            $type = $task['type'];
            if ($type !== static::TYPE_CO) {
                App::error(sprintf('Task %s is not a coroutine task.', $task['name']));
                continue;
            }

            $taskCos[] = TaskHelper::pack($task['name'], $task['method'], $task['params'], $task['type']);
        }

        $result = [];
        if (! empty($taskCos)) {
            $result = App::$server->getServer()->taskCo($tasks);
        }

        return $result;
    }
public static function co(array $tasks): array
    {
        $taskCos = [];
        foreach ($tasks as $task) {
            if (! isset($task['type']) || ! isset($task['name']) || ! isset($task['method']) || ! isset($task['params'])) {
                App::error(sprintf('Task %s format error.', $task['name'] ?? '[UNKNOWN]'));
                continue;
            }

            $type = $task['type'];
            if ($type !== static::TYPE_CO) {
                App::error(sprintf('Task %s is not a coroutine task.', $task['name']));
                continue;
            }

            $taskCos[] = TaskHelper::pack($task['name'], $task['method'], $task['params'], $task['type']);
        }

        $result = [];
        if (! empty($taskCos)) {
            $result = App::$server->getServer()->taskCo($tasks);
        }

        return $result;
    }
public static function co ( array $ tasks ) : array { $ taskCos = [ ] ; foreach ( $ tasks as $ task ) { if ( ! isset ( $ task [ 'type' ] ) || ! isset ( $ task [ 'name' ] ) || ! isset ( $ task [ 'method' ] ) || ! isset ( $ task [ 'params' ] ) ) { App :: error ( sprintf ( 'Task %s format error.' , $ task [ 'name' ] ?? '[UNKNOWN]' ) ) ; continue ; } $ type = $ task [ 'type' ] ; if ( $ type !== static :: TYPE_CO ) { App :: error ( sprintf ( 'Task %s is not a coroutine task.' , $ task [ 'name' ] ) ) ; continue ; } $ taskCos [ ] = TaskHelper :: pack ( $ task [ 'name' ] , $ task [ 'method' ] , $ task [ 'params' ] , $ task [ 'type' ] ) ; } $ result = [ ] ; if ( ! empty ( $ taskCos ) ) { $ result = App :: $ server -> getServer ( ) -> taskCo ( $ tasks ) ; } return $ result ; }
Deliver multiple coroutine tasks

@param array $tasks
<pre>
$tasks = [
'name'   => $taskName,
'method' => $methodName,
'params' => $params,
'type'   => $type
];
</pre>
Deliver multiple coroutine tasks