Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c095b69f67 | |||
| 4c8c5ac239 | |||
| cfc847133e | |||
| 30b430f1cf | |||
| 516c7612a5 | |||
| 3bb3d5a1d7 |
@@ -22,7 +22,7 @@ abstract class HttpService extends Component
|
||||
* @param string $category
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function write($message, $category = 'app')
|
||||
protected function write($message, string $category = 'app')
|
||||
{
|
||||
$logger = Snowflake::app()->getLogger();
|
||||
$logger->write($message, $category);
|
||||
|
||||
@@ -35,7 +35,6 @@ use function Co\run;
|
||||
* @package Snowflake
|
||||
*
|
||||
* @property-read Config $config
|
||||
* @property-read WchatProviders $wchat
|
||||
*/
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
@@ -62,6 +61,9 @@ class Application extends BaseApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param Closure|array $closure
|
||||
* @return $this
|
||||
|
||||
+22
-2
@@ -5,11 +5,12 @@ namespace Snowflake\Jwt;
|
||||
|
||||
use Exception;
|
||||
use HttpServer\Http\HttpHeaders;
|
||||
use Snowflake\Cache\Redis;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Cache\Redis;
|
||||
use Snowflake\Core\Json;
|
||||
use Snowflake\Core\Str;
|
||||
use Snowflake\Exception\AuthException;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
@@ -222,6 +223,25 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY=
|
||||
return $this->create($this->user, $headers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $headers
|
||||
* @return mixed
|
||||
* @throws AuthException
|
||||
*/
|
||||
public function getTokenUser(array $headers = []): int
|
||||
{
|
||||
$this->data = $headers;
|
||||
if (!openssl_public_decrypt(base64_decode($headers['refresh']), $data, $this->public)) {
|
||||
throw new AuthException('信息解码失败.');
|
||||
}
|
||||
|
||||
$data = Json::decode($data, true);
|
||||
|
||||
return (int)$data['user'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $param
|
||||
*
|
||||
|
||||
@@ -81,6 +81,11 @@ class ClientsPool extends Component
|
||||
{
|
||||
if (env('state') == 'exit') {
|
||||
Timer::clear($this->creates);
|
||||
foreach (static::$_connections as $channel) {
|
||||
$this->flush($channel, 0);
|
||||
$channel->close();
|
||||
}
|
||||
static::$_connections = [];
|
||||
$this->creates = -1;
|
||||
} else {
|
||||
$this->heartbeat_flush();
|
||||
@@ -131,7 +136,6 @@ class ClientsPool extends Component
|
||||
public function flush($channel, $retain_number)
|
||||
{
|
||||
$this->pop($channel, $retain_number);
|
||||
static::$_connections = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -180,12 +184,16 @@ class ClientsPool extends Component
|
||||
* @param $name
|
||||
* @return Channel
|
||||
* @throws ConfigException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getChannel($name): Channel
|
||||
{
|
||||
if (!isset(static::$_connections[$name])) {
|
||||
static::$_connections[$name] = new Channel(Config::get('databases.pool.max', 10));
|
||||
}
|
||||
if (static::$_connections[$name]->errCode == SWOOLE_CHANNEL_CLOSED){
|
||||
throw new Exception('Channel is Close.');
|
||||
}
|
||||
if ($this->creates === -1) {
|
||||
$this->creates = Timer::tick(60000, [$this, 'Heartbeat_detection']);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ abstract class Process extends \Swoole\Process implements SProcess
|
||||
|
||||
fire(Event::SERVER_WORKER_START);
|
||||
if (Snowflake::getPlatform()->isLinux()) {
|
||||
swoole_set_process_name($this->getProcessName());
|
||||
name($this->pid, $this->getProcessName());
|
||||
}
|
||||
if (method_exists($this, 'before')) {
|
||||
$this->before($process);
|
||||
|
||||
Reference in New Issue
Block a user