Bläddra i källkod

更新回收程序 机器人程序

郑晓宇 6 år sedan
förälder
incheckning
a98cf345ff
2 ändrade filer med 2 tillägg och 2 borttagningar
  1. 0 1
      app/Console/Commands/recylerobots.php
  2. 2 1
      app/Console/Commands/robot.php

+ 0 - 1
app/Console/Commands/recylerobots.php

@@ -47,7 +47,6 @@ class recylerobots extends Command
             if($robots){
                 foreach ($robots as $robot) {
                     $message['type'] = 'checkrobot';
-                    $message['client_id'] = $robot;
                     //检测是否在线
                     if(Gateway::isOnline($robot)){
                         Gateway::sendToClient($robot, json_encode($message));

+ 2 - 1
app/Console/Commands/robot.php

@@ -130,13 +130,14 @@ class robot extends Command
                 }
                 //获得题目
                 if($json_data->type == 'checkrobot'){
-                    if($room_id && $client_id){
+                    if(!empty($room_id) && !empty($client_id)){
                         $clients = Gateway::getClientIdListByGroup($room_id);
                         if(count($clients) > 0 && count($clients) < 2){
                             Gateway::leaveGroup($client_id, $room_id);
                             //重新加入机器人队列
                             Redis::sadd('robot_list', $client_id);
                             $room_id = '';
+                            echo "{$client_id} 离开房间:{$room_id}\n";
                             echo "{$client_id} 成功重回队列\n";
                         }
                     }