processor.php 1.2 KB

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