企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
<?php namespaceapp\\admin\\controller; use think\\worker\\Server; classWorkerextendsServer { protected $socket \="tcp://0.0.0.0:30000"; publicfunctiononWorkerStart($socket) { global $db;         $db \=new\\Workerman\\MySQL\\Connection('127.0.0.1','3306','root','123456','www\_test\_i'); } //接收数据 publicfunctiononMessage($connection, $data) { global $db;         $des \=bin2hex($data); var\_dump($des);         $r \=str\_split($des,2);         $strlen \=strlen($des); if($strlen \==66){             $d1 \=(hexdec($r\[3\]. $r\[4\]));             $d2 \=(hexdec($r\[5\]. $r\[6\]));             $d3 \=(hexdec($r\[7\]. $r\[8\]));             $bxz \=(hexdec($r\[15\]));             $bx \=(hexdec($r\[16\]. $r\[17\]));             $byf \=(hexdec($r\[18\])); // var\_dump($bx);             $by \=(hexdec($r\[19\]. $r\[20\]));             $bsk\_power \=hexdec($r\[25\]);             $bsk\_error \=hexdec($r\[26\]);             $status \=hexdec($r\[28\]); var\_dump($bxz, $byf, $status); // if ($status == 0) { if($bxz \==0|| $byf \==0){                 $db\->insert('kc\_sources')\->cols(array('sources'\=> $des, 'd1'\=> $d1, 'd2'\=> $d2, 'd3'\=> $d3, 'x'\=> $bx, 'y'\=> $by, 'status'\=> $status, 'bsk\_power'\=> $bsk\_power, 'bsk\_error'\=> $bsk\_error, 'insert\_time'\=>time()))\->query();                 $connection\->send("recive success"); }elseif($bxz \==1|| $byf \==1){                 $db\->insert('kc\_sources')\->cols(array('sources'\=> $des, 'd1'\=> $d1, 'd2'\=> $d2, 'd3'\=> $d3, 'x'\=>\-($bx), 'y'\=>\-($by), 'status'\=> $status, 'bsk\_power'\=> $bsk\_power, 'bsk\_error'\=> $bsk\_error, 'insert\_time'\=>time()))\->query();                 $connection\->send("hello"); }elseif($bxz \==0|| $byf \==1){                 $db\->insert('kc\_sources')\->cols(array('sources'\=> $des, 'd1'\=> $d1, 'd2'\=> $d2, 'd3'\=> $d3, 'x'\=> $bx, 'y'\=>\-($by), 'status'\=> $status, 'bsk\_power'\=> $bsk\_power, 'bsk\_error'\=> $bsk\_error, 'insert\_time'\=>time()))\->query();                 $connection\->send("hello"); }elseif($bxz \==1|| $byf \==0){                 $db\->insert('kc\_sources')\->cols(array('sources'\=> $des, 'd1'\=> $d1, 'd2'\=> $d2, 'd3'\=> $d3, 'x'\=>\-($bx), 'y'\=> $by, 'status'\=> $status, 'bsk\_power'\=> $bsk\_power, 'bsk\_error'\=> $bsk\_error, 'insert\_time'\=>time()))\->query();                 $connection\->send("hello"); } } } // 当有客户端连接断开时 //     public function onClose($connection) //     { //         global $worker; //         if (isset($connection->uid)) { //             // 连接断开时删除映射 //             unset($worker->uidConnections\[$connection->uid\]); //         } //     } // // 向所有验证的用户推送数据 //     public function broadcast($message) //     { //         global $worker; //         foreach ($worker->uidConnections as $connection) { //             $connection->send($message); //         } //     } // // 针对uid推送数据 //     public function sendMessageByUid($uid, $message) //     { //         global $worker; //         if (isset($worker->uidConnections\[$uid\])) { //             $connection = $worker->uidConnections\[$uid\]; //             $connection->send($message); //         } //     } }