郑晓宇 6 lat temu
rodzic
commit
9b2a403430

+ 11 - 8
app/Console/Commands/gamematch.php

@@ -50,13 +50,16 @@ class gamematch extends Command
             if(!$data){
                 echo "未找到匹配\n";
                 if($match_times > 3){
-                    $robot = Redis::lpop('robot_list');
-                    $message = [
-                        "type" => 'gotomatch',
-                    ];
-                    if($robot && Gateway::isOnline($robot)){
-                        Gateway::sendToClient($robot, $message);
-                        echo "启动机器人: {$robot}\n";
+                    $room = Redis::get($data['level']);
+                    if($room){
+                        $robot = Redis::lpop('robot_list');
+                        $message = [
+                            "type" => 'gotomatch',
+                        ];
+                        if($robot && Gateway::isOnline($robot)){
+                            Gateway::sendToClient($robot, json_encode($message));
+                            echo "启动机器人: {$robot}\n";
+                        }
                     }
                 }
                 sleep(1);
@@ -66,8 +69,8 @@ class gamematch extends Command
             $match_times = 0;
             $info = [];
             $questions = [];
-            $data = json_decode($data, 1);
             $room = Redis::get($data['level']);
+            $data = json_decode($data, 1);
             if($room){
                 Redis::del($data['level']);
                 $room = json_decode($room, 1);

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

@@ -90,6 +90,7 @@ class robot extends Command
                 }
                 //唤起匹配
                 if($json_data->type == 'gotomatch'){
+                    var_dump($json_data);
                     $response = $client->request('POST', 'http://183.234.61.252:8090/Home/Game/Join',[
                         'form_params' => [
                             'client_id' => $json_data->client_id,