diff --git a/platypush/backend/__init__.py b/platypush/backend/__init__.py index f7dc225b75..559f41e4a9 100644 --- a/platypush/backend/__init__.py +++ b/platypush/backend/__init__.py @@ -7,6 +7,7 @@ from threading import Thread from platypush.bus import Bus from platypush.config import Config +from platypush.context import get_backend from platypush.utils import get_message_class_by_type, set_timeout, clear_timeout from platypush.message import Message from platypush.message.event import Event, StopEvent @@ -186,13 +187,21 @@ class Backend(Thread): def send_message(self, msg, **kwargs): """ Sends a platypush.message.Message to a node. - To be implemented in the derived classes. - Always call send_request or send_response instead of send_message directly + To be implemented in the derived classes. By default, if the Redis + backend is configured then it will try to deliver the message to + other consumers through the configured Redis main queue. Param: msg -- The message """ - pass + try: + redis = get_backend('redis') + except KeyError: + self.logger.warning("Backend {} does not implement send_message " + + "and the fallback Redis backend isn't configured") + return + + redis.send_message(msg) def run(self): diff --git a/platypush/plugins/video/omxplayer.py b/platypush/plugins/video/omxplayer.py index 655a9764b9..38e22d5042 100644 --- a/platypush/plugins/video/omxplayer.py +++ b/platypush/plugins/video/omxplayer.py @@ -10,7 +10,6 @@ import urllib.parse from dbus.exceptions import DBusException from omxplayer import OMXPlayer -from platypush.context import get_bus from platypush.plugins.media import PlayerState from platypush.message.response import Response from platypush.message.event.video import VideoPlayEvent, VideoPauseEvent, \ @@ -198,17 +197,17 @@ class VideoOmxplayerPlugin(Plugin): def on_play(self): def _f(player): - get_bus().post(VideoPlayEvent(video=self.player.get_source())) + self.send_message(VideoPlayEvent(video=self.player.get_source())) return _f def on_pause(self): def _f(player): - get_bus().post(VideoPauseEvent(video=self.player.get_source())) + self.send_message(VideoPauseEvent(video=self.player.get_source())) return _f def on_stop(self): def _f(player): - get_bus().post(VideoStopEvent()) + self.send_message(VideoStopEvent()) return _f