|
|
|
Re: Python client - subclassing [message #1718416 is a reply to message #1233523] |
Wed, 23 December 2015 13:47 |
Martin Frlin Messages: 2 Registered: December 2015 |
Junior Member |
|
|
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:
class MQTTClient(mqtt.Client):
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):
print mesage.payload
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.04306 seconds