BoxSelectCmdServer.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mead
  5. * Date: 2019/9/3
  6. * Time: 8:05 PM
  7. */
  8. namespace App\Servers;
  9. use App\Models\CacheLogTraitModel;
  10. class BoxSelectCmdServer extends BaseServer
  11. {
  12. use CacheLogTraitModel;
  13. public function main($body)
  14. {
  15. $data = $this->decode($body);
  16. $this->cacheLog($data['msg_id'], $data['setting']);
  17. self::log($data, 'BoxSelectCmdServer', self::$LOG_MAJOR);
  18. return false;
  19. }
  20. /**
  21. * 解析装载的数据
  22. * @param $body
  23. * @return array
  24. * User: Mead
  25. */
  26. private function decode($body)
  27. {
  28. $arr = explode(BikeControl::SPLIT_TAG, implode('', $body));
  29. $setting = $_msg = $msg = '';
  30. if (count($arr) === 2) {
  31. list($setting, $_msg) = explode(BikeControl::SPLIT_TAG, implode('', $body));
  32. } else {
  33. $setting = $arr[0];
  34. }
  35. // $msg = $this->decodeMsgId($_msg);
  36. $setting = $this->decodeSetting($setting);
  37. return [
  38. 'setting' => $setting,
  39. 'msg_id' => $_msg,
  40. ];
  41. }
  42. }