protected function handleResponse($resp, $s, Set $tasks)
    {
        if (isset($resp['data']['handle']) &&
            $resp['function'] != 'job_created') {
            $task = $tasks->getTask($resp['data']['handle']);
        }

        switch ($resp['function']) {
        case 'work_complete':
            $tasks->tasksCount--;
            $task->complete($resp['data']['result']);
            break;
        case 'work_status':
            $n = (int) $resp['data']['numerator'];
            $d = (int) $resp['data']['denominator'];
            $task->status($n, $d);
            break;
        case 'work_fail':
            $tasks->tasksCount--;
            $task->fail();
            break;
        case 'job_created':
            $task = array_shift(Connection::$waiting[(int) $s]);
            $task->handle = $resp['data']['handle'];
            if ($task->type == Task::JOB_BACKGROUND) {
                $task->finished = true;
            }
            $tasks->handles[$task->handle] = $task->uniq;
            break;
        case 'error':
            throw new Exception('An error occurred');
        default:
            throw new Exception(
                'Invalid function ' . $resp['function']
            );
        }
    }
protected function handleResponse($resp, $s, Set $tasks)
    {
        if (isset($resp['data']['handle']) &&
            $resp['function'] != 'job_created') {
            $task = $tasks->getTask($resp['data']['handle']);
        }

        switch ($resp['function']) {
        case 'work_complete':
            $tasks->tasksCount--;
            $task->complete($resp['data']['result']);
            break;
        case 'work_status':
            $n = (int) $resp['data']['numerator'];
            $d = (int) $resp['data']['denominator'];
            $task->status($n, $d);
            break;
        case 'work_fail':
            $tasks->tasksCount--;
            $task->fail();
            break;
        case 'job_created':
            $task = array_shift(Connection::$waiting[(int) $s]);
            $task->handle = $resp['data']['handle'];
            if ($task->type == Task::JOB_BACKGROUND) {
                $task->finished = true;
            }
            $tasks->handles[$task->handle] = $task->uniq;
            break;
        case 'error':
            throw new Exception('An error occurred');
        default:
            throw new Exception(
                'Invalid function ' . $resp['function']
            );
        }
    }
protected function handleResponse ( $ resp , $ s , Set $ tasks ) { if ( isset ( $ resp [ 'data' ] [ 'handle' ] ) && $ resp [ 'function' ] != 'job_created' ) { $ task = $ tasks -> getTask ( $ resp [ 'data' ] [ 'handle' ] ) ; } switch ( $ resp [ 'function' ] ) { case 'work_complete' : $ tasks -> tasksCount -- ; $ task -> complete ( $ resp [ 'data' ] [ 'result' ] ) ; break ; case 'work_status' : $ n = ( int ) $ resp [ 'data' ] [ 'numerator' ] ; $ d = ( int ) $ resp [ 'data' ] [ 'denominator' ] ; $ task -> status ( $ n , $ d ) ; break ; case 'work_fail' : $ tasks -> tasksCount -- ; $ task -> fail ( ) ; break ; case 'job_created' : $ task = array_shift ( Connection :: $ waiting [ ( int ) $ s ] ) ; $ task -> handle = $ resp [ 'data' ] [ 'handle' ] ; if ( $ task -> type == Task :: JOB_BACKGROUND ) { $ task -> finished = true ; } $ tasks -> handles [ $ task -> handle ] = $ task -> uniq ; break ; case 'error' : throw new Exception ( 'An error occurred' ) ; default : throw new Exception ( 'Invalid function ' . $ resp [ 'function' ] ) ; } }
Handle the response read in.

@param array    $resp  The raw array response
@param resource $s     The socket
@param Set      $tasks The tasks being ran

@throws \MHlavac\Gearman\Exception
Handle the response read in .