Skip to content

Commit

Permalink
update: added laraquest polling method to core
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirHkrg committed Sep 6, 2024
1 parent ecd2eb8 commit 9fe4a4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use LaraGram\Container\Container;
use LaraGram\Contracts\Application as ApplicationContract;
use Illuminate\Database\Capsule\Manager as Capsule;
use LaraGram\Laraquest\Laraquest;
use LaraGram\Support\Facades\Config;
use LaraGram\Support\Facades\Console;
use Swoole\Http\Server;
Expand Down Expand Up @@ -494,7 +495,7 @@ public function loadResources($once = true): void
public function handleRequests()
{
$update_type = Config::get('bot.UPDATE_TYPE');
if ($update_type == 'openswoole' || $update_type == 'swoole') {
if ($update_type == 'openswoole') {
if (!extension_loaded('openswoole') && !extension_loaded('swoole')) {
Console::output()->failed('Extension Openswoole/Swoole not loaded!');
}
Expand All @@ -515,6 +516,10 @@ public function handleRequests()
});

$server->start();
}elseif($update_type == 'polling'){
Laraquest::polling(function (){
$this->loadResources(false);
});
} else {
$this->loadResources();
}
Expand Down
13 changes: 10 additions & 3 deletions src/Foundation/Server/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@ public function handle()
$command .= " & php -S {$DEVELOPMENT_SERVER_IP}:{$DEVELOPMENT_SERVER_PORT}";

exec($command);
}elseif ($this->getOption('openswoole') == 'openswoole' || $this->getOption('swoole') == 'swoole') {
if (Config::get('bot.UPDATE_TYPE') !== 'openswoole' || Config::get('bot.UPDATE_TYPE') !== 'swoole') {
Console::output()->failed("UPDATE_TYPE is not openswoole/swoole!", exit: true);
}elseif ($this->getOption('openswoole') == 'openswoole') {
if (Config::get('bot.UPDATE_TYPE') !== 'openswoole') {
Console::output()->failed("UPDATE_TYPE is not openswoole!", exit: true);
}

require_once 'Bootstrap/app.php';
}elseif ($this->getOption('polling') == 'polling') {
if (Config::get('bot.UPDATE_TYPE') !== 'polling') {
Console::output()->failed("UPDATE_TYPE is not polling!", exit: true);
}

require_once 'Bootstrap/app.php';
} else{
exec("php -S {$DEVELOPMENT_SERVER_IP}:{$DEVELOPMENT_SERVER_PORT}");
Expand Down

0 comments on commit 9fe4a4c

Please sign in to comment.