123456789101112131415161718192021222324252627282930 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
- @AUTHOR: ASJRD018
- @NAME: AnsjerFormal
- @software: PyCharm
- @DATE: 2019/3/7 9:42
- @Version: python3.6
- @MODIFY DECORD:ansjer dev
- @file: mqtt_server.py
- @Contact: chanjunkai@163.com
- """
- import paho.mqtt.client as mqtt
- def on_connect(client, userdata, flags, rc):
- print("Connected with result code " + str(rc))
- client.subscribe("chat")
- def on_message(client, userdata, msg):
- print(msg.topic + " " + ":" + str(msg.payload))
- client = mqtt.Client()
- client.on_connect = on_connect
- client.on_message = on_message
- client.connect("192.168.136.45", 1883, 60)
- client.loop_forever()
|