12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace Jiaruan;
- class ProtoCmdLine {
-
-
- public function proc( $req, $connmgr ){
- //检查签名
- if($req->sign != $this->sign_req($req) ) {
- log_error('check sign failed ' . json_encode($req));
- return $this->create_resp($req, false, "检查签名失败");
- }
-
- //生成下发基站的命令
- $cmd = $this->create_cmd($req);
-
- //下发命令给单个基站
- $result = $connmgr->send_one($req->station_number,$cmd);
- return $this->create_resp($req, $result['success'], $result['message']);
-
- }
-
-
- public function create_cmd( $req ){
- $config = array(
- "subtype" => 1,
- "cmd" => $req->cmdline,
- );
- $cmd = array(
- 'type' => 4,
- 'mac' => '??', //?? 表示由连接管理池发送时自动填充
- 'msgid' => 0,
- 'num' => 1,
- 'config' => array($config),
- );
- return $cmd;
- }
-
-
- public function create_resp( $req, $isSuccess, $message ){
- $resp = array(
- 'success' => $isSuccess,
- 'message' => $message
- );
- return $resp;
- }
-
-
- public function sign_req( $req ){
- $str = $req->type;
- $str.= $req->cityid;
- $str.= $req->station_number;
- $str.= $req->cmdline;
- $str.= C('协议签名密钥');
- return strtoupper(md5(urlencode($str)));
- }
-
- }
|