e
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
|
||||
|
||||
use Swoole\Coroutine;
|
||||
|
||||
abstract class BaseContext
|
||||
{
|
||||
protected static $pool = [];
|
||||
|
||||
static function get($key)
|
||||
{
|
||||
$cid = Coroutine::getuid();
|
||||
if ($cid < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(isset(self::$pool[$cid][$key])){
|
||||
return self::$pool[$cid][$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static function put($key, $item)
|
||||
{
|
||||
$cid = Coroutine::getuid();
|
||||
if ($cid > 0)
|
||||
{
|
||||
self::$pool[$cid][$key] = $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static function delete($key = null)
|
||||
{
|
||||
$cid = Coroutine::getuid();
|
||||
if ($cid > 0)
|
||||
{
|
||||
if($key){
|
||||
unset(self::$pool[$cid][$key]);
|
||||
}else{
|
||||
unset(self::$pool[$cid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
|
||||
use Snowflake\Abstracts\Component;
|
||||
|
||||
abstract class HttpService extends Component
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
use HttpServer\IInterface\IMiddleware;
|
||||
|
||||
/**
|
||||
* Class MiddlewareHandler
|
||||
* @package BeReborn\Route
|
||||
*/
|
||||
abstract class MiddlewareHandler implements IMiddleware
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: whwyy
|
||||
* Date: 2018/11/8 0008
|
||||
* Time: 18:37
|
||||
*/
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
|
||||
use HttpServer\Application;
|
||||
use Swoole\WebSocket\Server;
|
||||
|
||||
/**
|
||||
* Class ServerBase
|
||||
* @package BeReborn\Server
|
||||
*/
|
||||
abstract class ServerBase extends Application
|
||||
{
|
||||
|
||||
/** @var Server */
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer()
|
||||
{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $server
|
||||
*/
|
||||
public function setServer($server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user