郑晓宇 hace 6 años
padre
commit
f7e817964d
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  1. 7 5
      app/Console/Commands/robot.php

+ 7 - 5
app/Console/Commands/robot.php

@@ -122,20 +122,22 @@ class robot extends Command
                 //获得题目
                 if($json_data->type == 'answer'){
                     if($json_data->is_end == 1){
-                        echo "成功重回队列\n";
+                        $room_id = '';
+                        echo "{$client_id} 回答问题成功重回队列\n";
                         //重新加入机器人队列
-                        Redis::sadd('robot_list', $json_data->client_id);
+                        Redis::sadd('robot_list', $client_id);
                     }
                 }
                 //获得题目
                 if($json_data->type == 'checkrobot'){
                     if($room_id && $client_id){
                         $clients = Gateway::getClientIdListByGroup($room_id);
-                        if(count($clients) < 2){
+                        if(count($clients) > 0 && count($clients) < 2){
+                            Gateway::leaveGroup($client_id, $room_id);
+                            //重新加入机器人队列
+                            Redis::sadd('robot_list', $client_id);
                             $room_id = '';
                             echo "{$client_id} 成功重回队列\n";
-                            //重新加入机器人队列
-                            Redis::sadd('robot_list', $json_data->client_id);
                         }
                     }
                 }