BoxPlayVoiceServer.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. class BoxPlayVoiceServer extends BaseServer
  10. {
  11. public function main($body)
  12. {
  13. $data = $this->decode($body);
  14. self::log($data, 'BoxPlayVoiceServer', self::$LOG_MAJOR);
  15. return false;
  16. }
  17. /**
  18. * 解析装载的数据
  19. * @param $body
  20. * @return array
  21. * User: Mead
  22. */
  23. private function decode($body)
  24. {
  25. $i = 0;
  26. // 时间
  27. $time = self::stitching($body, $i, 4);
  28. $i += 4;
  29. // 执行结果
  30. $result = self::stitching($body, $i, 1);
  31. $i += 1;
  32. // 提示音指令
  33. $voice_cmd = self::stitching($body, $i, 2);
  34. $i += 2;
  35. //MsgId
  36. $msg_id = self::stitching($body, $i);
  37. $time = $this->decodeTime($time);
  38. return [
  39. 'time' => $time,
  40. 'result' => $result,
  41. 'voice_cmd' => $voice_cmd,
  42. 'msg_id' => $msg_id,
  43. ];
  44. }
  45. }