perf: only dispatch connect/disconnect events in onOpen and onClose

This commit is contained in:
Reasno 2020-05-25 10:30:11 +08:00
parent 15072ff79b
commit 5f07edb28a

View File

@ -157,11 +157,9 @@ class SocketIO implements OnMessageInterface, OnOpenInterface, OnCloseInterface
'nsp' => $packet->nsp,
]);
$server->push($frame->fd, Engine::MESSAGE . $this->encoder->encode($responsePacket)); //sever open
$this->dispatch($frame->fd, $packet->nsp, 'connect', $packet->data);
break;
case Packet::CLOSE: //client disconnect
$server->disconnect($frame->fd);
$this->dispatch($frame->fd, $packet->nsp, 'disconnect', $packet->data);
break;
case Packet::EVENT: // client message with ack
if ($packet->id !== '') {