add Middleware and release version 1.1.0

This commit is contained in:
whale
2020-03-29 16:29:02 +08:00
parent c2fcdf9668
commit 9a28126765
11 changed files with 175 additions and 21 deletions

View File

@@ -1,5 +1,8 @@
<?php
use Framework\ZMBuf;
use ZM\Utils\Context;
function classLoader($p) {
$filepath = getClassPath($p);
if ($filepath === null)
@@ -143,4 +146,20 @@ function matchArgs($pattern, $context) {
}
return $result;
} else return false;
}
}
function set_coroutine_params($array){
$cid = Co::getCid();
if($cid == -1) die("Cannot set coroutine params at none coroutine mode.");
ZMBuf::$context[$cid] = $array;
foreach(ZMBuf::$context as $c => $v) {
if(!Co::exists($c)) unset(ZMBuf::$context[$c]);
}
}
function context(){
$cid = Co::getCid();
if(isset(ZMBuf::$context[$cid])) {
return new Context(ZMBuf::$context[$cid], $cid);
} else return null;
}