src/controllers/ServerController.php
public function getVNCInfo($model, $enable = false)
    {
        if ($enable) {
            try {
                $vnc = Server::perform('enable-VNC', ['id' => $model->id]);
                $vnc['endTime'] = time() + 28800;
                Yii::$app->cache->set([__METHOD__, $model->id, $model], $vnc, 28800);
                $vnc['enabled'] = true;
            } catch (ResponseErrorException $e) {
                if ($e->getMessage() !== 'vds_has_tasks') {
                    throw $e;
                }
            }
        } else {
            if ($model->statuses['serverEnableVNC'] !== null && strtotime('+8 hours', strtotime($model->statuses['serverEnableVNC'])) > time()) {
                $vnc = Yii::$app->cache->getOrSet([__METHOD__, $model->id, $model], function () use ($model) {
                    return ArrayHelper::merge([
                        'endTime' => strtotime($model->statuses['serverEnableVNC']) + 28800,
                    ], Server::perform('enable-VNC', ['id' => $model->id]));
                }, 28800);
            }
            $vnc['enabled'] = $model->statuses['serverEnableVNC'] === null ? false : strtotime('+8 hours', strtotime($model->statuses['serverEnableVNC'])) > time();
        }

        return $vnc;
    }
public function getVNCInfo($model, $enable = false)
    {
        if ($enable) {
            try {
                $vnc = Server::perform('enable-VNC', ['id' => $model->id]);
                $vnc['endTime'] = time() + 28800;
                Yii::$app->cache->set([__METHOD__, $model->id, $model], $vnc, 28800);
                $vnc['enabled'] = true;
            } catch (ResponseErrorException $e) {
                if ($e->getMessage() !== 'vds_has_tasks') {
                    throw $e;
                }
            }
        } else {
            if ($model->statuses['serverEnableVNC'] !== null && strtotime('+8 hours', strtotime($model->statuses['serverEnableVNC'])) > time()) {
                $vnc = Yii::$app->cache->getOrSet([__METHOD__, $model->id, $model], function () use ($model) {
                    return ArrayHelper::merge([
                        'endTime' => strtotime($model->statuses['serverEnableVNC']) + 28800,
                    ], Server::perform('enable-VNC', ['id' => $model->id]));
                }, 28800);
            }
            $vnc['enabled'] = $model->statuses['serverEnableVNC'] === null ? false : strtotime('+8 hours', strtotime($model->statuses['serverEnableVNC'])) > time();
        }

        return $vnc;
    }
public function getVNCInfo ( $ model , $ enable = false ) { if ( $ enable ) { try { $ vnc = Server :: perform ( 'enable-VNC' , [ 'id' => $ model -> id ] ) ; $ vnc [ 'endTime' ] = time ( ) + 28800 ; Yii :: $ app -> cache -> set ( [ __METHOD__ , $ model -> id , $ model ] , $ vnc , 28800 ) ; $ vnc [ 'enabled' ] = true ; } catch ( ResponseErrorException $ e ) { if ( $ e -> getMessage ( ) !== 'vds_has_tasks' ) { throw $ e ; } } } else { if ( $ model -> statuses [ 'serverEnableVNC' ] !== null && strtotime ( '+8 hours' , strtotime ( $ model -> statuses [ 'serverEnableVNC' ] ) ) > time ( ) ) { $ vnc = Yii :: $ app -> cache -> getOrSet ( [ __METHOD__ , $ model -> id , $ model ] , function ( ) use ( $ model ) { return ArrayHelper :: merge ( [ 'endTime' => strtotime ( $ model -> statuses [ 'serverEnableVNC' ] ) + 28800 , ] , Server :: perform ( 'enable-VNC' , [ 'id' => $ model -> id ] ) ) ; } , 28800 ) ; } $ vnc [ 'enabled' ] = $ model -> statuses [ 'serverEnableVNC' ] === null ? false : strtotime ( '+8 hours' , strtotime ( $ model -> statuses [ 'serverEnableVNC' ] ) ) > time ( ) ; } return $ vnc ; }
Gets info of VNC on the server.

@param Server $model
@param bool $enable
@throws ResponseErrorException
@return array
Gets info of VNC on the server .