EventProc.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 框架封装的一部分通用/常见Event.
  5. * @version
  6. * 1.0.0 Created at 2017-8-28. by --gwang
  7. * @author gwang (mail@wanggangzero.cn)
  8. * @copyright ? 2017-8-28, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  9. */
  10. class EventProc {
  11. public static function procMain($req) {
  12. switch ($req->cmd) {
  13. case CmdCode::cmd_event_GetNotifications: # 7201 拉取角标通知列表
  14. return self::GetCornerSignNotifications($req);
  15. default:
  16. return Resp::err(ErrCode::cmd_err);
  17. }
  18. }
  19. //put your code here
  20. /**
  21. * [7201] 拉取角标通知
  22. * @param req $req
  23. */
  24. static function GetCornerSignNotifications($req) {
  25. // 这里直接返回, 将来开发对应的触发逻辑, 给数组中添加相应的值
  26. $arr = array_values(array_unique($req->userInfo->game->privateState->cornerSignNotifications)); # 返回值去重
  27. $req->userInfo->game->privateState->cornerSignNotifications = []; # 清理记录
  28. UserProc::updateUserInfo();
  29. return Resp::ok(array("notifications" => $arr)); # 返回
  30. }
  31. static function Init() {
  32. Event::register('onpay', array(new UserProfile(req()->userInfo->game->profile), "OnPay"));
  33. }
  34. /**
  35. * 收到请求
  36. */
  37. static function OnRequest() {
  38. }
  39. /**
  40. * 处理完毕准备返回
  41. */
  42. static function AfterResponse() {
  43. }
  44. /**
  45. * 当天第一次登录
  46. */
  47. static function OnNewDay() {
  48. }
  49. /**
  50. * 当周第一次登录(周一)
  51. */
  52. static function OnNewWeek() {
  53. }
  54. }