Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Sep 27, 2019
1 parent 382588f commit 3a57e81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/Cache/Handler/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,8 @@ protected function checkExpire($fileName)
*/
protected function writeExData($fileName, $ttl)
{
$data = [
file_put_contents($this->getExDataFileName($fileName), serialize([
'ttl' => $ttl,
];
file_put_contents($this->getExDataFileName($fileName), serialize($data));
]));
}
}
12 changes: 4 additions & 8 deletions src/Server/Http/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ protected function bindEvents()
{
$this->swooleServer->handle('/', is_callable($event) ? $event : function(\Swoole\Http\Request $swooleRequest, \Swoole\Http\Response $swooleResponse){
try{
$request = Request::getInstance($this, $swooleRequest);
$response = Response::getInstance($this, $swooleResponse);
$this->trigger('request', [
'request' => $request,
'response' => $response,
'request' => Request::getInstance($this, $swooleRequest),
'response' => Response::getInstance($this, $swooleResponse),
], $this, RequestEventParam::class);
}
catch(\Throwable $ex)
Expand Down Expand Up @@ -125,11 +123,9 @@ protected function __bindEvents()
{
$server->on('request', is_callable($event) ? $event : function(\Swoole\Http\Request $swooleRequest, \Swoole\Http\Response $swooleResponse){
try{
$request = Request::getInstance($this, $swooleRequest);
$response = Response::getInstance($this, $swooleResponse);
$this->trigger('request', [
'request' => $request,
'response' => $response,
'request' => Request::getInstance($this, $swooleRequest),
'response' => Response::getInstance($this, $swooleResponse),
], $this, RequestEventParam::class);
}
catch(\Throwable $ex)
Expand Down
6 changes: 2 additions & 4 deletions src/Server/WebSocket/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ protected function __bindEvents()
{
$server->on('handshake', is_callable($event) ? $event : function(\Swoole\Http\Request $swooleRequest, \Swoole\Http\Response $swooleResponse){
try{
$request = new Request($this, $swooleRequest);
$response = new Response($this, $swooleResponse);
$this->trigger('handShake', [
'request' => &$request,
'response' => &$response,
'request' => new Request($this, $swooleRequest),
'response' => new Response($this, $swooleResponse),
], $this, HandShakeEventParam::class);
}
catch(\Throwable $ex)
Expand Down

0 comments on commit 3a57e81

Please sign in to comment.