mycroft-messagebus-client


Namemycroft-messagebus-client JSON
Version 0.10.1 PyPI version JSON
download
home_pagehttps://github.com/MycroftAI/mycroft-messagebus-client
SummaryMycroft Messagebus Client
upload_time2022-10-12 18:24:30
maintainer
docs_urlNone
authorMycroft AI, Åke Forslund
requires_python
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements websocket-client pyee
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Mycroft Bus Client

This module is a simple interface for the mycroft messagebus and can be used to connect to mycroft, send messages and react to messages sent by the Mycroft 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 mycroftr core on the default endpoint and port.


## 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 mycroft_bus_client import MessageBusClient, Message

print('Setting up client to connect to a local mycroft 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 mycroft_bus_client import MessageBusClient, Message

print('Setting up client to connect to a local mycroft instance')
client = MessageBusClient()

def print_utterance(message):
    print('Mycroft 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/MycroftAI/mycroft-messagebus-client",
    "name": "mycroft-messagebus-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mycroft AI, \u00c5ke Forslund",
    "author_email": "devs@mycroft.ai, ake.forslund@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/75/da/3840283b54522c5fdf65d0c76a22a6194e0a03266399c9794cb861f06455/mycroft-messagebus-client-0.10.1.tar.gz",
    "platform": null,
    "description": "\n# Mycroft Bus Client\n\nThis module is a simple interface for the mycroft messagebus and can be used to connect to mycroft, send messages and react to messages sent by the Mycroft 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 mycroftr core on the default endpoint and port.\n\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 mycroft_bus_client import MessageBusClient, Message\n\nprint('Setting up client to connect to a local mycroft 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 mycroft_bus_client import MessageBusClient, Message\n\nprint('Setting up client to connect to a local mycroft instance')\nclient = MessageBusClient()\n\ndef print_utterance(message):\n    print('Mycroft 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": "Mycroft Messagebus Client",
    "version": "0.10.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "6c4e65c3ffed2545f5e6ad86809ca3d6",
                "sha256": "ffb6a09c171586eb2bd07de3d5221d26725ce73a2dcbb418d2b8a2e4a7f59494"
            },
            "downloads": -1,
            "filename": "mycroft_messagebus_client-0.10.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6c4e65c3ffed2545f5e6ad86809ca3d6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23739,
            "upload_time": "2022-10-12T18:24:29",
            "upload_time_iso_8601": "2022-10-12T18:24:29.479788Z",
            "url": "https://files.pythonhosted.org/packages/b3/a4/5cd6333bf3ebd700abb8be59540f97dbb7bdf703195f9beb130a601c5867/mycroft_messagebus_client-0.10.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "466a910c1cd1b8ad80d10e92861d7822",
                "sha256": "db7d2d08050d37112ccbf07381a7145f69e2a2cdb5d18d9b4322450e66c4f51b"
            },
            "downloads": -1,
            "filename": "mycroft-messagebus-client-0.10.1.tar.gz",
            "has_sig": false,
            "md5_digest": "466a910c1cd1b8ad80d10e92861d7822",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20097,
            "upload_time": "2022-10-12T18:24:30",
            "upload_time_iso_8601": "2022-10-12T18:24:30.602075Z",
            "url": "https://files.pythonhosted.org/packages/75/da/3840283b54522c5fdf65d0c76a22a6194e0a03266399c9794cb861f06455/mycroft-messagebus-client-0.10.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-12 18:24:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "MycroftAI",
    "github_project": "mycroft-messagebus-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "websocket-client",
            "specs": [
                [
                    ">=",
                    "0.54.0"
                ]
            ]
        },
        {
            "name": "pyee",
            "specs": [
                [
                    "==",
                    "8.1.0"
                ]
            ]
        }
    ],
    "lcname": "mycroft-messagebus-client"
}
        
Elapsed time: 0.04582s