public function receive(): ?array
    {
        if (!$this->isConnected()) {
            return null;
        }

        $data = $this->socket->receive();

        if (!$data) {
            return [];
        }

        $this->payloadHandler->handle($data);
        $received = $this->received;
        $this->received = [];
        return $received;
    }