Initial commit
This commit is contained in:
commit
2d18417793
7 changed files with 218 additions and 0 deletions
28
mock-actor/mock-actor.py
Normal file
28
mock-actor/mock-actor.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import paho.mqtt.client as mqtt
|
||||
|
||||
# The callback for when the client receives a CONNACK response from the server.
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
print("Connected with result code "+str(rc))
|
||||
# Subscribing in on_connect() means that if we lose the connection and
|
||||
# reconnect then subscriptions will be renewed.
|
||||
print("Subscribing to topic","mlmAccess/pair/response/actor")
|
||||
print(client.subscribe("mlmAccess/pair/response/actor"))
|
||||
print("Publishing message to topic","mlmAccess/pair/request/actor")
|
||||
print(client.publish("mlmAccess/pair/request/actor", "101"))
|
||||
|
||||
def on_message(client, userdata, message):
|
||||
print("message received " ,str(message.payload.decode("utf-8")))
|
||||
print("message topic=",message.topic)
|
||||
print("message qos=",message.qos)
|
||||
print("message retain flag=",message.retain)
|
||||
|
||||
client = mqtt.Client(client_id="pair-actor")
|
||||
client.username_pw_set("pair-actor", "pair-actor")
|
||||
|
||||
client.on_connect = on_connect
|
||||
client.on_message = on_message
|
||||
|
||||
print("connecting to broker")
|
||||
print(client.connect("localhost", 1883, 60))
|
||||
|
||||
client.loop_forever()
|
Loading…
Add table
Add a link
Reference in a new issue