https://github.com/nxtlo/batteries
A messaging service between devices.
https://github.com/nxtlo/batteries
messaging zeromq zmq
Last synced: 2 months ago
JSON representation
A messaging service between devices.
- Host: GitHub
- URL: https://github.com/nxtlo/batteries
- Owner: nxtlo
- License: bsd-3-clause
- Created: 2022-04-04T05:59:58.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-22T16:38:32.000Z (over 2 years ago)
- Last Synced: 2025-02-15T20:54:05.699Z (4 months ago)
- Topics: messaging, zeromq, zmq
- Language: Python
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# batteries
A robust communication service between devices and websocket server using ZeroMQ.## Example application
```py
from message_service import gateway, devices, enums# server.py
server = gateway.Gateway()await server.open()
# clients.py
# Connect to the gateway.
device = devices.Device()await device.open()
# Send a signal to the gateway that we want to open connection.
await device.signal(enums.Signal.OPEN)
# Restart the device.
await device.signal(enums.Signal.RESTART)
# Close.
await device.close()```
### Results in
```py
INFO:connector: Connected to gateway...
DEBUG:connector: Device IP: 172.17.8.209 Name: web-22 Event: OPEN
INFO:connector: {'web-22': DeviceView(host_name='web-22', ip_address='172.17.8.209', mac_address='85:03:45:1c:b6:9b', signal=)}
DEBUG:connector: Device IP: 172.17.8.209 Name: web-22 Event: RESTART
INFO:connector: Restarting device web-22
DEBUG:connector: Device IP: 172.17.8.209 Name: web-22 Event: CLOSE
```