SystemController.php
1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?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);
}
}