private function routeCurrentFrame()
    {
        $this->logger->debug("Routing frame");

        $opcode = $this->currentFrame->getOpcode();
        if ($opcode === DataFrame::OPCODE_TEXT || $opcode === DataFrame::OPCODE_BINARY || $opcode === DataFrame::OPCODE_CONTINUE) { //Non-control frame
            if ($this->currentMessage === null) //No message in processing - new need to be build
            {
                $this->logger->debug("No message, creating new");
                $this->currentMessage = new Message($this->logger, $this->currentFrame);

            } else { //Only first frame should contain a type
                $this->logger->debug("Adding frame to message");
                $this->currentMessage->addFrame($this->currentFrame);
            }

            if ($this->currentMessage->isComplete()) {
                $this->logger->debug("Message completed, routing");
                $this->handleMessage($this->currentMessage);
                $this->currentMessage = null; //Message is completed, API has been notified so no need to hold it here

            } else {
                $this->logger->debug("Message not completed yet");
            }

        } elseif ($opcode === DataFrame::OPCODE_CLOSE) {
            $this->handleClientCloseFrame($this->currentFrame);

        } elseif ($opcode === DataFrame::OPCODE_PING) {
            $this->handlePingFrame($this->currentFrame);

        } elseif ($opcode === DataFrame::OPCODE_PONG) {
            $this->handlePongFrame($this->currentFrame);

        } else {
            throw new WebSocketException("Non-RFC or reserved opcode, or first message frame with continue opcode",
                DataFrame::CODE_PROTOCOL_ERROR);
        }

        $this->currentFrame = null;
        $this->logger->debug("Frame routing completed");
    }