PushListenerCommand.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * 消息推送监听脚本
  4. * @author >
  5. */
  6. class PushListenerCommand extends CConsoleCommand{
  7. public function run($args) {
  8. error_reporting(E_ERROR);
  9. ini_set('memory_limit', '512M');
  10. ignore_user_abort(true);
  11. set_time_limit(0);
  12. $time_H = time();
  13. while (true) {
  14. sleep(2);
  15. $time = time();
  16. if($time - $time_H > 3600){
  17. exit();
  18. }
  19. //信鸽消息推送队列,
  20. $list = new ARedisList('xinge_push');
  21. $z_push = new ZPush();
  22. echo $list->getCount();
  23. while ($list->getCount() > 0) {
  24. try {
  25. $res = $list->pop();
  26. $data = unserialize($res);
  27. $result = $z_push->PushSingleAccountIOS($data['ios_data']);
  28. $result2 = $z_push->PushSingleAccountAndroid($data['android_data']);
  29. } catch (Exception $e) {
  30. continue;
  31. }
  32. }
  33. }
  34. }
  35. }