AppController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * AppController.php UTF-8
  4. * 游戏入口
  5. *
  6. * @date : 2017/11/15 17:21
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\apple\controller\v8;
  13. use api\common\controller\AppleApiBaseController;
  14. use huo\controller\app\App;
  15. use huo\controller\game\Game;
  16. use huo\controller\member\OauthOut;
  17. use huo\controller\message\Message;
  18. use huo\controller\notice\Notice;
  19. use think\Session;
  20. class AppController extends AppleApiBaseController {
  21. public function _initialize() {
  22. parent::_initialize();
  23. }
  24. /**
  25. * app启动(激活)
  26. * http://doc.1tsdk.com/138?page_id=2896
  27. * 【域名】/a/startup
  28. */
  29. public function startup() {
  30. // TODO: wuyonghong 2018/1/19 先校验请求参数
  31. // $result = $this->validate($this->rq_data, 'App.startup');
  32. // if ($result !== true) {
  33. // $this->error($result);
  34. // }
  35. $_game_rq = $this->setGameData();
  36. $_channel_rq = $this->setChannelData();
  37. $_device_rq = $this->setDeviceData();
  38. $_game_class = new Game();
  39. $_rdata['up'] = $_game_class->getUpInfo($_game_rq, $_channel_rq);
  40. $_notice_class = new Notice();
  41. $_rdata['notice'] = $_notice_class->getNotice($_game_rq, $_channel_rq, $_device_rq);
  42. $_rdata['hb_time'] = 120;
  43. $_rdata['user_token'] = session_id();
  44. $_rdata['toggle'] = 1;// TODO: wuyonghong 2018/4/24 需要添加函数
  45. $_rdata['agentgame'] = $_channel_rq->getAgentGame();
  46. $_rdata['oauth_list'] = (new OauthOut())->getOauthConf();
  47. Session::set('open_cnt', $this->rq_data['open_cnt']);
  48. Session::set('app_id', $_game_rq->getHAppId(), 'app');
  49. $this->success(lang('SUCCESS'), $_rdata);
  50. }
  51. /**
  52. * SDK事件上报
  53. * http://doc.1tsdk.com/138?page_id=2951
  54. * 【域名】/a/event
  55. */
  56. public function event() {
  57. $_game_rq = $this->setGameData();
  58. $_channel_rq = $this->setChannelData();
  59. $_device_rq = $this->setDeviceData();
  60. $_event_rq = $this->setEventData();
  61. $_app_class = new App();
  62. $_rs = $_app_class->insertLog($_event_rq, $_game_rq, $_channel_rq, $_device_rq);
  63. if (false !== $_rs) {
  64. $this->success(lang('SUCCESS'));
  65. }
  66. $this->error(lang('ERROR'));
  67. }
  68. /**
  69. * APP心跳
  70. * http://doc.1tsdk.com/138?page_id=2898
  71. * 【域名】/a/heartbeat
  72. */
  73. public function heartbeat() {
  74. $_game_rq = $this->setGameData();
  75. $_channel_rq = $this->setChannelData();
  76. $_device_rq = $this->setDeviceData();
  77. $_mem_rq = $this->setMemData();
  78. $_app_class = new App();
  79. $_app_class->insertHeartLog($_game_rq, $_channel_rq, $_device_rq, $_mem_rq);
  80. $_msg_class = new Message();
  81. $_param = $this->request->param();
  82. $_mem_id = $this->mem_id;
  83. $_rdata['msg_cnt'] = $_msg_class->getCnt($_param, $_mem_id);
  84. $this->success(lang('SUCCESS'), $_rdata);
  85. }
  86. /**
  87. * APP奔溃
  88. * http://doc.1tsdk.com/138?page_id=2897
  89. * 【域名】/a/crash
  90. */
  91. public function crash() {
  92. $_game_rq = $this->setGameData();
  93. $_channel_rq = $this->setChannelData();
  94. $_device_rq = $this->setDeviceData();
  95. $_crash_rq = $this->setCrashData();
  96. $_app_class = new App();
  97. $_rs = $_app_class->insertCrashLog($_crash_rq, $_game_rq, $_channel_rq, $_device_rq);
  98. if (false !== $_rs) {
  99. $this->success(lang('SUCCESS'));
  100. }
  101. $this->error(lang('ERROR'));
  102. }
  103. }