Merge pull request #170 from limingxinleo/websocket

Fixed some bug for websocket-server.
This commit is contained in:
李铭昕 2019-07-08 18:53:36 +08:00 committed by GitHub
commit f591561a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -20,6 +20,7 @@
- [#148](https://github.com/hyperf-cloud/hyperf/pull/148) Fixed cannot generate the migration when migrates directory does not exist.
- [#152](https://github.com/hyperf-cloud/hyperf/pull/152) Fixed db connection will not be closed when a low use frequency.
- [#169](https://github.com/hyperf-cloud/hyperf/pull/169) Fixed array parse failed when handle http request.
- [#170](https://github.com/hyperf-cloud/hyperf/pull/170) Fixed websocket server interrupt when request a not exist route.
# Removed

View File

@ -15,6 +15,7 @@ namespace Hyperf\WebSocketServer\Exception\Handler;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\ExceptionHandler\ExceptionHandler;
use Hyperf\ExceptionHandler\Formatter\FormatterInterface;
use Hyperf\HttpMessage\Stream\SwooleStream;
use Psr\Http\Message\ResponseInterface;
use Throwable;

View File

@ -39,7 +39,7 @@ class Security
];
}
public function sign(string $key): string
public function sign(string $key): string
{
return base64_encode(sha1(trim($key) . self::KEY, true));
}

View File

@ -124,14 +124,16 @@ class Server implements MiddlewareInitializerInterface, OnHandShakeInterface, On
$class = $psr7Response->getAttribute('class');
FdCollector::set($request->fd, $class);
if (! empty($class)) {
FdCollector::set($request->fd, $class);
defer(function () use ($request, $class) {
$instance = $this->container->get($class);
if ($instance instanceof OnOpenInterface) {
$instance->onOpen($this->server, $request);
}
});
defer(function () use ($request, $class) {
$instance = $this->container->get($class);
if ($instance instanceof OnOpenInterface) {
$instance->onOpen($this->server, $request);
}
});
}
} catch (\Throwable $throwable) {
// Delegate the exception to exception handler.
$exceptionHandlerDispatcher = $this->container->get(ExceptionHandlerDispatcher::class);