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

Uploaded Source

Built Distribution

mycroft_messagebus_client-0.8.5-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mycroft-messagebus-client-0.8.5.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.3

File hashes

Hashes for mycroft-messagebus-client-0.8.5.tar.gz
Algorithm Hash digest
SHA256 ec1895bbe69c4da643d75026da4f2494936588755190f311889c6cbd18a82c7a
MD5 b5c741ed2e86ec79a2ecdac4d46bd365
BLAKE2b-256 b6d29506e3e0c6cefe93d4a4e610192dc106d75301ab6fec83d490a61a17fd3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mycroft_messagebus_client-0.8.5-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.3

File hashes

Hashes for mycroft_messagebus_client-0.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d98c5a6c843f332a455e1e638e4f8876cbc3fe965e84706e340f1bb818df1a7d
MD5 d0efefd2f44525e88a2d86b7102b54f2
BLAKE2b-256 77d09318e1053236f0c11da3ec58cf9eda4a783a48068febf87b139f4a0ff94d

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