(→Example) |
(→Example) |
||
Line 3: | Line 3: | ||
== Example == | == Example == | ||
− | + | ``` | |
− | + | import socketio | |
− | + | ||
− | + | sio = socketio.Client() | |
− | + | ||
− | def | + | @sio.event |
− | print(' | + | def connect(): |
+ | print('connected to server') | ||
− | + | @sio.event | |
− | + | def disconnect(): | |
− | def | + | print('disconnected from server') |
− | + | ||
− | + | ||
− | + | ||
− | + | @sio.on("mqtt") | |
− | + | def on_mqtt(data): | |
− | + | print (data) | |
− | + | return | |
− | socket. | + | |
− | + | sio.connect(url='https://api.brandmeister.network', socketio_path="/lh/socket.io", transports="websocket") | |
− | + | sio.wait() | |
+ | ``` |
pip install socketIO-client
``` import socketio
sio = socketio.Client()
@sio.event def connect():
print('connected to server')
@sio.event def disconnect():
print('disconnected from server')
@sio.on("mqtt") def on_mqtt(data):
print (data) return
sio.connect(url='https://api.brandmeister.network', socketio_path="/lh/socket.io", transports="websocket") sio.wait() ```
pip install socketIO-client
``` import socketio
sio = socketio.Client()
@sio.event def connect():
print('connected to server')
@sio.event def disconnect():
print('disconnected from server')
@sio.on("mqtt") def on_mqtt(data):
print (data) return
sio.connect(url='https://api.brandmeister.network', socketio_path="/lh/socket.io", transports="websocket") sio.wait() ```