# 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.
```python
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.
```python
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
```python
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()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/OpenVoiceOS/ovos-bus-client",
"name": "ovos-bus-client",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "JarbasAI",
"author_email": "jarbas@openvoiceos.com",
"download_url": "https://files.pythonhosted.org/packages/d6/06/6efb0672252ce69703379c8a5e96ff4c7078bb1054d8a179ebb9e81b7a37/ovos-bus-client-1.0.6.tar.gz",
"platform": null,
"description": "# OpenVoiceOS Bus Client\n\nThis 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.\n\n\n## MycroftBusClient()\n\nThe `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.\n\n> NOTE: we kept the original pre-fork class name for compatibility reasons\n\n## Message()\n\nThe `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.\n\n```python\nMessage('MESSAGE_TYPE', data={'meaning': 42}, context={'origin': 'A.Dent'})\n```\n\n## Examples\n\nBelow are some a couple of simple cases for sending a message on the bus as well\nas reacting to messages on the bus\n\n### Sending a message on the bus.\n\n```python\nfrom ovos_bus_client import MessageBusClient, Message\n\nprint('Setting up client to connect to a local OVOS instance')\nclient = MessageBusClient()\nclient.run_in_thread()\n\nprint('Sending speak message...')\nclient.emit(Message('speak', data={'utterance': 'Hello World'}))\n```\n\n### Catching a message on the messagebus\n\n```python\nfrom ovos_bus_client import MessageBusClient, Message\n\nprint('Setting up client to connect to a local OVOS instance')\nclient = MessageBusClient()\n\ndef print_utterance(message):\n print('OVOS said \"{}\"'.format(message.data.get('utterance')))\n\n\nprint('Registering handler for speak message...')\nclient.on('speak', print_utterance)\n\nclient.run_forever()\n```\n\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "OVOS Messagebus Client",
"version": "1.0.6",
"project_urls": {
"Homepage": "https://github.com/OpenVoiceOS/ovos-bus-client"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c94efd613f8a2bd2d134a54246bea44edc7c8baeba32ec9d2af66137b41c4eca",
"md5": "fb9d2641c7557a74c79e9869bc00679a",
"sha256": "ecece71853442293d4a5d9b432399d4b05ad3ba45493e711dd8e4aec36563149"
},
"downloads": -1,
"filename": "ovos_bus_client-1.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fb9d2641c7557a74c79e9869bc00679a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 50657,
"upload_time": "2024-11-26T19:03:37",
"upload_time_iso_8601": "2024-11-26T19:03:37.227762Z",
"url": "https://files.pythonhosted.org/packages/c9/4e/fd613f8a2bd2d134a54246bea44edc7c8baeba32ec9d2af66137b41c4eca/ovos_bus_client-1.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d6066efb0672252ce69703379c8a5e96ff4c7078bb1054d8a179ebb9e81b7a37",
"md5": "878348805ce118e653eab96380ae53cd",
"sha256": "6f7ee927c4d9ff93b34dbbe902237e8c2cd31700fe667cb79b9411ca8a2b4980"
},
"downloads": -1,
"filename": "ovos-bus-client-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "878348805ce118e653eab96380ae53cd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 44360,
"upload_time": "2024-11-26T19:03:39",
"upload_time_iso_8601": "2024-11-26T19:03:39.084419Z",
"url": "https://files.pythonhosted.org/packages/d6/06/6efb0672252ce69703379c8a5e96ff4c7078bb1054d8a179ebb9e81b7a37/ovos-bus-client-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 19:03:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "OpenVoiceOS",
"github_project": "ovos-bus-client",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "ovos-config",
"specs": [
[
"<",
"2.0.0"
],
[
">=",
"0.0.12"
]
]
},
{
"name": "ovos-utils",
"specs": [
[
">=",
"0.3.5"
],
[
"<",
"1.0.0"
]
]
},
{
"name": "websocket-client",
"specs": [
[
">=",
"0.54.0"
]
]
},
{
"name": "pyee",
"specs": [
[
"<",
"13.0.0"
],
[
">=",
"8.1.0"
]
]
},
{
"name": "orjson",
"specs": []
}
],
"lcname": "ovos-bus-client"
}