processor.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  3. class processor extends queue\ILooper
  4. {
  5. private $mProxy;
  6. public function __construct()
  7. {
  8. parent::__construct(new queue\DispatcherServer());
  9. $this->mProxy = new proxy();
  10. }
  11. protected function handle($msg)
  12. {
  13. if (empty($msg)) {
  14. Log::record('empty body', Log::DEBUG);
  15. }
  16. else
  17. {
  18. foreach ($msg as $key => $params)
  19. {
  20. Log::record("start one", Log::DEBUG);
  21. if (empty($params)) continue;
  22. $method = strtolower($key);
  23. try
  24. {
  25. if ($method == 'add') {
  26. $this->mProxy->add($params);
  27. } elseif ($method == 'notify') {
  28. $channel = $params['channel'];
  29. $input = $params['input'];
  30. $this->mProxy->notify($channel,$input);
  31. } else {
  32. Log::record("Error msg", Log::DEBUG);
  33. }
  34. } catch (Exception $x) {
  35. Log::record($x->getMessage(), Log::ERR);
  36. }
  37. }
  38. }
  39. }
  40. }