mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Fixed bug that the socket-io
server always restart when using coroutine style server. (#4854)
This commit is contained in:
parent
c8d4d666aa
commit
bb3f034c7d
@ -105,3 +105,4 @@ composer analyse
|
||||
- [#4549](https://github.com/hyperf/hyperf/pull/4549) Fixed bug that `PhpParser::getExprFromValue()` does not support assoc array.
|
||||
- [#4835](https://github.com/hyperf/hyperf/pull/4835) Fixed the lost description when using property `$description` and `$signature` for `hyperf/command`.
|
||||
- [#4851](https://github.com/hyperf/hyperf/pull/4851) Fixed bug that prometheus server will not be closed automatically when using command which enable event dispatcher.
|
||||
- [#4854](https://github.com/hyperf/hyperf/pull/4854) Fixed bug that the `socket-io` client always reconnect when using coroutine style server.
|
||||
|
@ -27,6 +27,7 @@ use Hyperf\SocketIOServer\Parser\Packet;
|
||||
use Hyperf\SocketIOServer\Room\EphemeralInterface;
|
||||
use Hyperf\SocketIOServer\SidProvider\SidProviderInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\WebSocketServer\Constant\Opcode;
|
||||
use Hyperf\WebSocketServer\Sender;
|
||||
use Swoole\Atomic;
|
||||
use Swoole\Http\Request;
|
||||
@ -105,6 +106,15 @@ class SocketIO implements OnMessageInterface, OnOpenInterface, OnCloseInterface
|
||||
*/
|
||||
public function onMessage($server, $frame): void
|
||||
{
|
||||
if ($frame->opcode == Opcode::PING) {
|
||||
if ($server instanceof Response) {
|
||||
$server->push('', Opcode::PONG);
|
||||
} else {
|
||||
$server->push($frame->fd, '', Opcode::PONG);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($frame->data[0] === Engine::PING) {
|
||||
$this->renewInAllNamespaces($frame->fd);
|
||||
if ($server instanceof Response) {
|
||||
|
Loading…
Reference in New Issue
Block a user