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.2.tar.gz (14.1 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.8.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mycroft-messagebus-client-0.8.2.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.3

File hashes

Hashes for mycroft-messagebus-client-0.8.2.tar.gz
Algorithm Hash digest
SHA256 538cf379e041f96849990d57a6780db08670d8c5262ed48fd647c875d3d2d038
MD5 15fa53503a8a59dd150bbf56c76065b9
BLAKE2b-256 70e660a06715e50cc1bfe62eb03795eb905d68ad42c2bf8c0d69d6db53e584e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mycroft_messagebus_client-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.3

File hashes

Hashes for mycroft_messagebus_client-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fdea2dfabc94c1b6318814c16940acec10c136a16608cd4edc3edf1f73b6f51b
MD5 00fba538dd95a0caf2ce0d5b78e869b8
BLAKE2b-256 70eeba3ccfda1928d00eebe8fcc768d3155e2c699a80651e2532441e2b3acfb1

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