Skip to main content

Mycroft Messagebus Client

Project description

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.

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 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

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mycroft-messagebus-client-0.9.2.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mycroft_messagebus_client-0.9.2-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file mycroft-messagebus-client-0.9.2.tar.gz.

File metadata

  • Download URL: mycroft-messagebus-client-0.9.2.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.3

File hashes

Hashes for mycroft-messagebus-client-0.9.2.tar.gz
Algorithm Hash digest
SHA256 c457337b4b25c62cbd846fab87e8a771c9246bec921a6aa0ac1f9f8116a7fbb6
MD5 2c0a6eccdf821543c0aeadac4d97b62d
BLAKE2b-256 5eba6bb4b4bffa2a3f286a4ffde3361de72421c6dd6a7f636c0d9712eb52e77f

See more details on using hashes here.

File details

Details for the file mycroft_messagebus_client-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: mycroft_messagebus_client-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.3

File hashes

Hashes for mycroft_messagebus_client-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46200b2631dc6aa0bfbce7eab54a6182fd51e669e49c27b0e3dee999d103a212
MD5 1860cae263d4b578aa0b6c80f5ee84b1
BLAKE2b-256 a49531125323c98d36cfd81e2fa423710638c3ba74683454e6ddadec0baab403

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page