|
@@ -71,7 +71,7 @@ class robot extends Command
|
|
|
$con = new AsyncTcpConnection('ws://183.234.61.252:8282');
|
|
|
$con->onConnect = function($con) use($client) {
|
|
|
};
|
|
|
- $con->onMessage = function($con, $data) use($client, $room_id, $client_id){
|
|
|
+ $con->onMessage = function($con, $data) use($client, &$room_id, &$client_id){
|
|
|
//注册地址
|
|
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
|
|
//格式化参数
|
|
@@ -129,9 +129,14 @@ class robot extends Command
|
|
|
}
|
|
|
//获得题目
|
|
|
if($json_data->type == 'checkrobot'){
|
|
|
- echo "{$client_id} 成功重回队列\n";
|
|
|
- //重新加入机器人队列
|
|
|
- Redis::sadd('robot_list', $json_data->client_id);
|
|
|
+ if($room_id && $client_id){
|
|
|
+ $clients = Gateway::getClientIdListByGroup($room_id);
|
|
|
+ if(count($clients) < 2){
|
|
|
+ echo "{$client_id} 成功重回队列\n";
|
|
|
+ //重新加入机器人队列
|
|
|
+ Redis::sadd('robot_list', $json_data->client_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
$con->connect();
|