发布消息

        - 样例:

        .. code:: python

            t = {
                'hostname': '192.168.1.2',
                'port': 1883,
                'username': 'admin',
                'password': 'admin',
            }
            Publisher(t).run({'payload': json.dumps(t)}) if pub else TopicConsumer(t).run()

        :param dat:
        :type dat:
        :return:
        :rtype:

def run(self, dat=None):
        """
            发布消息

        - 样例:

        .. code:: python

            t = {
                'hostname': '192.168.1.2',
                'port': 1883,
                'username': 'admin',
                'password': 'admin',
            }
            Publisher(t).run({'payload': json.dumps(t)}) if pub else TopicConsumer(t).run()

        :param dat:
        :type dat:
        :return:
        :rtype:
        """
        conf = self.conf
        dat = dat if dat else {}
        publish.single(topic=dat.get('topic', 'test_topic'),
                       payload=dat.get('payload', 'just a test topic payload'),
                       qos=dat.get('qos', 0),
                       retain=dat.get('retain', False),
                       hostname=conf['hostname'],
                       port=conf['port'],
                       auth=conf['auth'])