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.3.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

mycroft_messagebus_client-0.9.3-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mycroft-messagebus-client-0.9.3.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for mycroft-messagebus-client-0.9.3.tar.gz
Algorithm Hash digest
SHA256 155636799fab2696b3c6b26e55fa219a71fd3b3a6198da86d5cf15911ee401dd
MD5 c294547321842a660b486fcfcc4118d1
BLAKE2b-256 a98bf69b99fea4a528f7a716674fe842be2075038a93d0bfb85fbbaa0468178a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mycroft_messagebus_client-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for mycroft_messagebus_client-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3683042d35001d09293ac6bf5e9fcc65a929f2b1a0d6aa28d7d039c1091a1594
MD5 64fa8af0b1a9ddc2ed8c223f7981a72f
BLAKE2b-256 cf20b5681c37ea8d652b63e60745ebba7df8b9b1119b1646bcb402b9465aca38

See more details on using hashes here.

Supported by

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