12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Mead
- * Date: 2019/9/3
- * Time: 8:05 PM
- */
- namespace App\Servers;
- class RemoteCmdServer extends BaseServer
- {
- public function main($body)
- {
- $data = $this->decode($body);
- self::log($data, 'RemoteCmdServer', self::$LOG_MAJOR);
- if ($data['result'] === '02') {
- // //运动中
- self::log($data['msgId']['no'], 'REMOTECMD_LOSE', self::$LOG_COMMON);
- BikeControl::outAreaLoseElectric($data['msgId']['no']);
- sleep(1);
- switch ($data['msgId']['cmd']) {
- case BikeControl::CONTROL_REMOTE_CLOSE_LOCK:
- //关锁处理
- BikeControl::closeLock($data['msgId']['no']);
- break;
- case BikeControl::CONTROL_REMOTE_TEMPORARY_CLOSE_LOCK:
- //临时锁车处理
- BikeControl::temporaryCloseLock($data['msgId']['no']);
- break;
- }
- }
- return $this->response(self::RESULT_SUCCESS);
- }
- // 登录成功
- const RESULT_SUCCESS = '01';
- // 登录失败
- const RESULT_FAIL = '00';
- /**
- * 登录响应
- * @param $login_type
- * @return array
- * User: Mead
- */
- public function response($result_type = '01')
- {
- $body = [
- $result_type,
- ];
- return $body;
- }
- /**
- * 解析装载的登录数据
- * @param $body
- * @return array
- * User: Mead
- */
- private function decode($body)
- {
- $i = 0;
- $result = self::stitching($body, $i, 1);
- $i += 1;
- //标识符
- $i += 2;
- $msgId = self::stitching($body, $i);
- $msgId = $this->decodeMsgId($msgId);
- return [
- 'result' => $result,
- 'msgId' => $msgId
- ];
- }
- }
|