/** * @param \DIServer\Interfaces\IRequest $request 当前请求 * @param \Closure $next 下一个中间件的方法引用 */ public function Handle(IRequest $request, \Closure $next) { //Log::Debug('Session Middleware Start'); SessionService::Start($request->GetFD()); $response = $next($request); //Log::Debug('Session Middleware Close'); SessionService::Close(); return $response; }
protected function unpackHandlerID(IRequest $request) { $data = $request->GetData(); $handlerID = null; if (strlen($data) >= 8) { $handlerID = unpack('x4/i1HandlerID', $data); if ($handlerID) { $handlerID = array_pop($handlerID); } } return $handlerID; }