|Re: Python client - subclassing [message #1718416 is a reply to message #1233523]
||Wed, 23 December 2015 13:47
| Martin Frlin
Registered: December 2015
Sorry for resurrecting an old thread.|
Any advice on how to subclass the Client?
I'm having troubles with callbacks.
This does not work for example:
def __init__(self, client_id='', clean_session=True, userdata=None, protocol=mqtt.MQTTv31):
super(MQTTClient, self).__init__(client_id, clean_session, userdata, protocol)
self.on_message = self.on_message_cb
def on_message_cb(self, userdata, message):
The best thing would be if on_message would not be defined in __init__ but it would be an emptu funtion in mqtt.Client. Then you would just redefine the function in your own class.
Powered by FUDForum
. Page generated in 0.02144 seconds