OVOS Messagebus Client
Project description
OpenVoiceOS Bus Client
This module is a simple interface for the OVOS messagebus and can be used to connect to OVOS, send messages and react to messages sent by the OpenVoiceOS system.
MycroftBusClient()
The MycroftBusClient()
object can be setup to connect to any host and port as well as any endpont on that host. this makes it quite versitile and will work on the main bus as well as on a gui bus. If no arguments are provided it will try to connect to a local instance of OVOS on the default endpoint and port.
NOTE: we kept the original pre-fork class name for compatibility reasons
Message()
The Message
object is a representation of the messagebus message, this will always contain a message type but can also contain data and context. Data is usually real information while the context typically contain information on where the message originated or who the intended recipient is.
Message('MESSAGE_TYPE', data={'meaning': 42}, context={'origin': 'A.Dent'})
Examples
Below are some a couple of simple cases for sending a message on the bus as well as reacting to messages on the bus
Sending a message on the bus.
from ovos_bus_client import MessageBusClient, Message
print('Setting up client to connect to a local OVOS instance')
client = MessageBusClient()
client.run_in_thread()
print('Sending speak message...')
client.emit(Message('speak', data={'utterance': 'Hello World'}))
Catching a message on the messagebus
from ovos_bus_client import MessageBusClient, Message
print('Setting up client to connect to a local OVOS instance')
client = MessageBusClient()
def print_utterance(message):
print('OVOS said "{}"'.format(message.data.get('utterance')))
print('Registering handler for speak message...')
client.on('speak', print_utterance)
client.run_forever()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ovos-bus-client-1.0.4a1.tar.gz
.
File metadata
- Download URL: ovos-bus-client-1.0.4a1.tar.gz
- Upload date:
- Size: 44.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3c51d3f2885e0560fef5b1a5592d93fd7dd1039735f569dc73a80ff7f97ad84 |
|
MD5 | 44390e38d68c8bb4976cb0eb41b11d9f |
|
BLAKE2b-256 | 7753a3228aa6b8c3867a0a2cc718691833e55f61bc6f660c918720d68bd18dcb |
File details
Details for the file ovos_bus_client-1.0.4a1-py3-none-any.whl
.
File metadata
- Download URL: ovos_bus_client-1.0.4a1-py3-none-any.whl
- Upload date:
- Size: 50.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e78a5a797c0467c0a0297c29efc1aef84e1607331012df7d3096d5f3a1f39f5 |
|
MD5 | 54e85b858ab2a2fc3c56cb53f7679d72 |
|
BLAKE2b-256 | f23abecd64e30ddc6473fe44d6011d0973430e46c243c2cdd81d7645df56a3ab |