| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App\Console\Commands\Redis;
- use App\Http\logic\api\ExtensionLogic;
- use App\Jobs\Demo1;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Redis;
- class FissionCommand extends Command
- {
- // 1005=>TP、2030=>Rummy、2050=>Rummy两人、2060=>TPJoker玩法、2061=>TPAK玩法、2070=>Rummy10Card、2090=>Rummy两人十张
- // 2010=>百人TP、 2012=>百人AB 暂时忽略
- protected $GameIDs = [1005, 2030, 2050, 2060, 2061, 2070, 2090];
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'fission';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '裂变-游戏对局';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $logic = new ExtensionLogic();
- // $redis = new \Redis();
- // $redis->connect('8.129.91.11', '16973');
- // $redis->auth('0949jfi959t*fbf0o');
- $redis = Redis::connection('test');
- echo 'Start' . "\n";
- // 出栈
- while (true) {
- $brPop = $redis->brPop('gameCount', 0);
- $ret = $brPop[1] ?? 0;
- if (!empty($ret)) {
- $ret = explode(',', $ret);
- if (in_array($ret[1], $this->GameIDs)) {
- $UserID = $ret[0];
- $logic->invitation($UserID, 2);
- sleep(2);
- }
- }
- }
- }
- public function handle1()
- {
- dispatch(new Demo1());
- }
- }
|