改名
This commit is contained in:
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
|
||||
use Database\Connection;
|
||||
use Exception;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Event;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Kiri;
|
||||
|
||||
|
||||
/**
|
||||
* Class Callback
|
||||
* @package HttpServer\Abstracts
|
||||
*/
|
||||
abstract class Callback extends HttpService
|
||||
{
|
||||
|
||||
|
||||
const EVENT_ERROR = 'WORKER:ERROR';
|
||||
const EVENT_STOP = 'WORKER:STOP';
|
||||
const EVENT_EXIT = 'WORKER:EXIT';
|
||||
|
||||
|
||||
private array $_MESSAGE = [
|
||||
self::EVENT_ERROR => 'The server error. at No.',
|
||||
self::EVENT_STOP => 'The server stop. at No.',
|
||||
self::EVENT_EXIT => 'The server exit. at No.',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param $messageContent
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function system_mail($messageContent)
|
||||
{
|
||||
try {
|
||||
$email = Config::get('email');
|
||||
if (empty($email) || !$email['enable']) {
|
||||
return;
|
||||
}
|
||||
$transport = (new \Swift_SmtpTransport($email['host'], $email['465']))
|
||||
->setUsername($email['username'])
|
||||
->setPassword($email['password']);
|
||||
$mailer = new \Swift_Mailer($transport);
|
||||
|
||||
// Create a message
|
||||
$message = (new \Swift_Message('Wonderful Subject'))
|
||||
->setFrom([$email['send']['address'] => $email['send']['nickname']])
|
||||
->setBody('Here is the message itself');
|
||||
|
||||
foreach ($email['receive'] as $item) {
|
||||
$message->setTo([$item['address'], $item['address'] => $item['nickname']]);
|
||||
}
|
||||
$mailer->send($messageContent);
|
||||
} catch (\Throwable $e) {
|
||||
$this->addError($e, 'email');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ConfigException
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function clearMysqlClient()
|
||||
{
|
||||
$databases = Config::get('databases', []);
|
||||
if (empty($databases)) {
|
||||
return;
|
||||
}
|
||||
$application = Kiri::app();
|
||||
foreach ($databases as $name => $database) {
|
||||
/** @var Connection $connection */
|
||||
$connection = $application->get('databases.' . $name, false);
|
||||
if (empty($connection)) {
|
||||
continue;
|
||||
}
|
||||
$connection->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $clientInfo
|
||||
* @param string $event
|
||||
* @return string
|
||||
*/
|
||||
protected function getName(array $clientInfo, string $event): string
|
||||
{
|
||||
return 'listen ' . $clientInfo['server_port'] . ' ' . Event::SERVER_CONNECT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ConfigException
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function clearRedisClient()
|
||||
{
|
||||
$redis = Kiri::app()->getRedis();
|
||||
$redis->destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: whwyy
|
||||
* Date: 2018/11/8 0008
|
||||
* Time: 18:37
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
|
||||
use Swoole\WebSocket\Server;
|
||||
|
||||
/**
|
||||
* Class OnServerDefault
|
||||
* @package Kiri\Kiri\Server
|
||||
*/
|
||||
abstract class ServerBase extends HttpService
|
||||
{
|
||||
|
||||
/** @var Server */
|
||||
protected Server $server;
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer(): Server
|
||||
{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $server
|
||||
*/
|
||||
public function setServer($server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user