Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wwj718/dynatalk-py
https://github.com/wwj718/dynatalk-py
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/wwj718/dynatalk-py
- Owner: wwj718
- Created: 2024-03-26T04:19:36.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-06T07:42:07.000Z (6 months ago)
- Last Synced: 2024-06-06T08:59:07.019Z (6 months ago)
- Language: Python
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
Awesome Lists containing this project
README
# dynatalk-py
This repository is the Python client of [Dynatalk](https://github.com/wwj718/Dynatalk).
> Dynatalk focuses on communication among objects, especially concerning interoperability among different languages/environments. -- [Dynatalk](https://github.com/wwj718/Dynatalk).
To use Dynatalk, you need to:
1. [Run an MQTT broker](https://github.com/wwj718/Dynatalk/blob/main/mqtt/readme.md)
2. Start programming with the dynatalk client.## Install
```bash
pip install dynatalk
```## get started
```py
from dynatalk import Supervisor, PyDemoAgentsupervisor = Supervisor()
# The agent object can work as a server (providing services to other agents) or work as a client (requesting services from other agents).
agent = PyDemoAgent("PyDemoAgent") # PyDemoAgent provides two services: add, echo
supervisor.addAgent(agent)# As a **client**, agent requests PyDemoAgent to execute add, the parameters are [1, 2]
agent.request("PyDemoAgent", "add", [1 ,2])
# agent.request("LivelyDemoAgent", "add", [1, 2])# Unlike request, sendTo does not require a response
# agent.sendTo...
```to discover agents on the current network:
```py
agent.broadcastHelp()
time.sleep(1)
print(agent.availableActions)
```## CLi tools
### dynatalk message monitor
```bash
dynatalk-monitor
```## FAQ
### Set up MQTT
Use environment variables to set up MQTT.
default is:
```
MQTT_HOST: 127.0.0.1
MQTT_PORT: 1883
MQTT_USERNAME: guest
MQTT_PASSWORD: test
```[How to set environment variables in Python?](https://stackoverflow.com/questions/5971312/how-to-set-environment-variables-in-python)