123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- /**
- * AppController.php UTF-8
- * 游戏入口
- *
- * @date : 2017/11/15 17:21
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace api\apple\controller\v8;
- use api\common\controller\AppleApiBaseController;
- use huo\controller\app\App;
- use huo\controller\game\Game;
- use huo\controller\member\OauthOut;
- use huo\controller\message\Message;
- use huo\controller\notice\Notice;
- use think\Session;
- class AppController extends AppleApiBaseController {
- public function _initialize() {
- parent::_initialize();
- }
- /**
- * app启动(激活)
- * http://doc.1tsdk.com/138?page_id=2896
- * 【域名】/a/startup
- */
- public function startup() {
- // TODO: wuyonghong 2018/1/19 先校验请求参数
- // $result = $this->validate($this->rq_data, 'App.startup');
- // if ($result !== true) {
- // $this->error($result);
- // }
- $_game_rq = $this->setGameData();
- $_channel_rq = $this->setChannelData();
- $_device_rq = $this->setDeviceData();
- $_game_class = new Game();
- $_rdata['up'] = $_game_class->getUpInfo($_game_rq, $_channel_rq);
- $_notice_class = new Notice();
- $_rdata['notice'] = $_notice_class->getNotice($_game_rq, $_channel_rq, $_device_rq);
- $_rdata['hb_time'] = 120;
- $_rdata['user_token'] = session_id();
- $_rdata['toggle'] = 1;// TODO: wuyonghong 2018/4/24 需要添加函数
- $_rdata['agentgame'] = $_channel_rq->getAgentGame();
- $_rdata['oauth_list'] = (new OauthOut())->getOauthConf();
- Session::set('open_cnt', $this->rq_data['open_cnt']);
- Session::set('app_id', $_game_rq->getHAppId(), 'app');
- $this->success(lang('SUCCESS'), $_rdata);
- }
- /**
- * SDK事件上报
- * http://doc.1tsdk.com/138?page_id=2951
- * 【域名】/a/event
- */
- public function event() {
- $_game_rq = $this->setGameData();
- $_channel_rq = $this->setChannelData();
- $_device_rq = $this->setDeviceData();
- $_event_rq = $this->setEventData();
- $_app_class = new App();
- $_rs = $_app_class->insertLog($_event_rq, $_game_rq, $_channel_rq, $_device_rq);
- if (false !== $_rs) {
- $this->success(lang('SUCCESS'));
- }
- $this->error(lang('ERROR'));
- }
- /**
- * APP心跳
- * http://doc.1tsdk.com/138?page_id=2898
- * 【域名】/a/heartbeat
- */
- public function heartbeat() {
- $_game_rq = $this->setGameData();
- $_channel_rq = $this->setChannelData();
- $_device_rq = $this->setDeviceData();
- $_mem_rq = $this->setMemData();
- $_app_class = new App();
- $_app_class->insertHeartLog($_game_rq, $_channel_rq, $_device_rq, $_mem_rq);
- $_msg_class = new Message();
- $_param = $this->request->param();
- $_mem_id = $this->mem_id;
- $_rdata['msg_cnt'] = $_msg_class->getCnt($_param, $_mem_id);
- $this->success(lang('SUCCESS'), $_rdata);
- }
- /**
- * APP奔溃
- * http://doc.1tsdk.com/138?page_id=2897
- * 【域名】/a/crash
- */
- public function crash() {
- $_game_rq = $this->setGameData();
- $_channel_rq = $this->setChannelData();
- $_device_rq = $this->setDeviceData();
- $_crash_rq = $this->setCrashData();
- $_app_class = new App();
- $_rs = $_app_class->insertCrashLog($_crash_rq, $_game_rq, $_channel_rq, $_device_rq);
- if (false !== $_rs) {
- $this->success(lang('SUCCESS'));
- }
- $this->error(lang('ERROR'));
- }
- }
|