App.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * App.php UTF-8
  4. * APP事件异步处理--生产者
  5. *
  6. * @date : 2018/5/30 16:43
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\controller\queue;
  13. use huo\controller\request\Channel;
  14. use huo\controller\request\Crash;
  15. use huo\controller\request\Device;
  16. use huo\controller\request\Game;
  17. use huolib\queue\constant\EventConst;
  18. class App extends SdkQueue {
  19. /**
  20. * app激活
  21. * 记录客户端被激活日志,用户下载APP后第一次打开客户端时调用。
  22. * http://doc.1tsdk.com/138?page_id=3375
  23. *
  24. * @param Device $device_rq
  25. * @param Game $game_rq
  26. * @param Channel $agent_rq
  27. *
  28. * @return array
  29. */
  30. public function activation(Device $device_rq, Game $game_rq, Channel $agent_rq) {
  31. $this->param['event'] = EventConst::EVENT_APP_ACTIVATION;
  32. $this->setParamDevice($device_rq);
  33. $this->setParamGame($game_rq);
  34. $this->setParamChannel($agent_rq);
  35. return $this->pushQueue();
  36. }
  37. /**
  38. * app启动
  39. * 记录客户端被启动日志,用户激活客户端后,每次跳转到SDK登录界面时调用。
  40. *
  41. * http://doc.1tsdk.com/138?page_id=3376
  42. * @param Device $device_rq
  43. * @param Game $game_rq
  44. * @param Channel $agent_rq
  45. *
  46. * @return array
  47. */
  48. public function startup(Device $device_rq, Game $game_rq, Channel $agent_rq) {
  49. $this->param['event'] = EventConst::EVENT_APP_STARTUP;
  50. $this->setParamDevice($device_rq);
  51. $this->setParamGame($game_rq);
  52. $this->setParamChannel($agent_rq);
  53. return $this->pushQueue();
  54. }
  55. /**
  56. * app崩溃
  57. * 记录客户端异常的日志,用户激活无法跳转到SDK登录界面、闪退等异常情况时调用。
  58. * http://doc.1tsdk.com/138?page_id=3377
  59. *
  60. * @param Device $device_rq
  61. * @param Game $game_rq
  62. * @param Channel $agent_rq
  63. * @param Crash $crash_rq
  64. *
  65. * @return array
  66. */
  67. public function crash(Device $device_rq, Game $game_rq, Channel $agent_rq, Crash $crash_rq) {
  68. $this->param['event'] = EventConst::EVENT_APP_CRASH;
  69. $this->setParamDevice($device_rq);
  70. $this->setParamGame($game_rq);
  71. $this->setParamChannel($agent_rq);
  72. $this->param['crash'] = [
  73. 'active' => $crash_rq->getActive(),
  74. 'msg' => $crash_rq->getMsg(),
  75. ];
  76. return $this->pushQueue();
  77. }
  78. /**
  79. * app心跳
  80. * 客户端每2分钟上报一次客户端活跃状态的事件
  81. * http://doc.1tsdk.com/138?page_id=3378
  82. *
  83. * @param Device $device_rq
  84. * @param Game $game_rq
  85. * @param Channel $agent_rq
  86. *
  87. * @return array
  88. */
  89. public function heartbeat(Device $device_rq, Game $game_rq, Channel $agent_rq) {
  90. $this->param['event'] = EventConst::EVENT_APP_HEARTBEAT;
  91. $this->setParamDevice($device_rq);
  92. $this->setParamGame($game_rq);
  93. $this->setParamChannel($agent_rq);
  94. return $this->pushQueue();
  95. }
  96. }