kopia lustrzana https://github.com/Yakifo/amqtt
Change context init
rodzic
22c7ef674e
commit
3147dee4bd
|
@ -116,8 +116,9 @@ class BrokerContext(BaseContext):
|
|||
BrokerContext is used as the context passed to plugins interacting with the broker.
|
||||
It act as an adapter to broker services from plugins developed for HBMQTT broker
|
||||
"""
|
||||
def __init__(self, loop=None):
|
||||
super().__init__(loop)
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.config = None
|
||||
|
||||
|
||||
class Broker:
|
||||
|
@ -177,7 +178,9 @@ class Broker:
|
|||
self.sys_handle = None
|
||||
|
||||
# Init plugins manager
|
||||
self.plugins_manager = PluginManager('hbmqtt.broker.plugins', BrokerContext(self._loop), self._loop)
|
||||
context = BrokerContext()
|
||||
context.config = self.config
|
||||
self.plugins_manager = PluginManager('hbmqtt.broker.plugins', context, self._loop)
|
||||
|
||||
def _build_listeners_config(self, broker_config):
|
||||
self.listeners_config = dict()
|
||||
|
|
|
@ -38,8 +38,9 @@ class ClientContext(BaseContext):
|
|||
ClientContext is used as the context passed to plugins interacting with the client.
|
||||
It act as an adapter to client services from plugins
|
||||
"""
|
||||
def __init__(self, client):
|
||||
super().__init__(client._loop)
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.config = None
|
||||
|
||||
|
||||
class MQTTClient:
|
||||
|
@ -89,7 +90,9 @@ class MQTTClient:
|
|||
self._connection_closed_future = None
|
||||
|
||||
# Init plugins manager
|
||||
self.plugins_manager = PluginManager('hbmqtt.client.plugins', ClientContext(self))
|
||||
context = ClientContext()
|
||||
context.config = self.config
|
||||
self.plugins_manager = PluginManager('hbmqtt.client.plugins', context)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
|
|
@ -22,11 +22,8 @@ def get_plugin_manager(namespace):
|
|||
|
||||
|
||||
class BaseContext:
|
||||
def __init__(self, loop=None):
|
||||
if loop is not None:
|
||||
self._loop = loop
|
||||
else:
|
||||
self._loop = asyncio.get_event_loop()
|
||||
def __init__(self):
|
||||
self.loop = None
|
||||
self.logger = None
|
||||
|
||||
|
||||
|
@ -48,6 +45,7 @@ class PluginManager:
|
|||
self.context = BaseContext()
|
||||
else:
|
||||
self.context = context
|
||||
context.loop = loop
|
||||
self._plugins = []
|
||||
self._load_plugins(namespace)
|
||||
self._fired_events = []
|
||||
|
|
Ładowanie…
Reference in New Issue