31 lines
679 B
JavaScript
31 lines
679 B
JavaScript
// //1
|
|
// import { File } from '@asyncapi/generator-react-sdk'
|
|
// //2
|
|
// export default function ({ asyncapi }) {
|
|
// //3
|
|
// return <File name="client.py">{asyncapi.info().title()}</File>
|
|
// }
|
|
|
|
|
|
|
|
import { File } from '@asyncapi/generator-react-sdk';
|
|
|
|
export default function ({ asyncapi }) {
|
|
return (
|
|
<File name="client.py">
|
|
{`import paho.mqtt.client as mqtt
|
|
|
|
mqttBroker = "test.mosquitto.org"
|
|
|
|
class TemperatureServiceClient:
|
|
def __init__(self):
|
|
self.client = mqtt.Client()
|
|
self.client.connect(mqttBroker)
|
|
|
|
|
|
def sendTemperatureChange(self, id):
|
|
topic = "temperature/changed"
|
|
self.client.publish(topic, id)`}
|
|
</File>
|
|
)
|
|
} |