public function sendRealMessageToDevice(Message $message, Device $device, $user = null, Request $request = null)
    {
        if ($this->isDisabled()) {
            return false;
        }

        $em = $this->container->get('doctrine')->getManager();

        $config = $this->container->getParameter('sopinet_chat.config');

        $messageData = $message->getMyMessageObject($this->container, $request);

        $text = $message->__toString();

        $messageArray = array();

        $vars = get_object_vars($messageData);

        foreach($vars as $key => $value) {
            $messageArray[$key] = $value;
        }

        if ($message->getChat() != null) {
            $em = $this->container->get('doctrine.orm.default_entity_manager');

            /** @var ChatRepository $repositoryChat */
            $repositoryChat = $em->getRepository('SopinetChatBundle:Chat');
            $repositoryChat->enabledChat($message->getChat());

            $chatData = $message->getChat()->getMyAddMessageObject($this->container);
            $varsChat = get_object_vars($chatData);
            foreach($varsChat as $key => $value) {
                $messageArray[$key] = $value;
            }
        }

        if ($user != null) {
            $messageArray['toUserId'] = $user->getId();

            //Calculamos el numero de mensajes pendientes que tiene

            // Get MessagePackage
            $reMessagePackage = $em->getRepository("SopinetChatBundle:MessagePackage");
            $messagesPackage = $reMessagePackage->findBy(array(
                'toUser' => $user->getId(),
                'toDevice' => $device->getDeviceId(),
                'processed' => false
            ));

            //Añadimos uno para que cuente el actual mensaje
            $messageArray['badge'] = count($messagesPackage) + 1;
        }else{
            $messageArray['badge'] = 0;
        }

        if ($device->getDeviceType() == Device::TYPE_ANDROID && $config['enabledAndroid']) {
            return $this->sendGCMessage($messageArray, $text, $device->getDeviceGCMId());
        } elseif ($device->getDeviceType() == Device::TYPE_IOS && $config['enabledIOS']) {
            return $this->sendAPNMessage($messageArray, $text, $device->getDeviceId(), $message->getMyIOSContentAvailable(), $message->getMyIOSNotificationFields());
        } elseif ($device->getDeviceType() == Device::TYPE_WEB && $config['enabledWeb']) {
            return $this->sendWebMessage($messageArray, $text, $device->getDeviceId());
        } elseif ($device->getDeviceType() == Device::TYPE_VIRTUALNONE) {
            // Do Nothing, but return true, so, state = 1, it is "sent" (in virtualnone: saved)
            return true;
        }
    }