SystemController.php 1017 Bytes
<?php
namespace soa\controllers\v1;

use Yii;
use soa\controllers\BaseController;
use common\models\SysConfig;
/**
 * Site controller
 */
class SystemController extends BaseController
{
    /**
     * 获取弹幕服务host:port
     */
    public function actionGethosts()
    {
        $type = Yii::$app->request->get('type');
        $model = new SysConfig();
        $hosts = $model->getServerAddr();
        switch($type){
            case 'tcp':
                $ret = $hosts['tcp'];
                break;
            case 'websocket':
                $ret = $hosts['websocket'];
                break;
            default:
                $ret = $hosts['tcp'];
        }
        $this->renderJson(Yii::$app->params['success_code'],'',$ret);
    }

    /**
     * 获取所有弹幕服务器
     */
    public function actionGetservers()
    {
        $model = new SysConfig();
        $servers = $model->getValues('servers');
        $this->renderJson(Yii::$app->params['success_code'],'',$servers);
    }
}