Skip to main content

Connect easily to a spacebro server

Project description

pySpacebroClient

🌟 Connect easily to a [spacebro server](https://github.com/spacebro/spacebro).

a port of nodejs spacebro-client

Why

No more custom socket.io server.

Easily connect with socket.io to other clients.

Spacebro offers an API to connect clients input and output together.

Installation

pip install pySpacebroClient

Usage

  1. Connect
from pySpacebroClient import SpacebroClient

settings = {
    'host': 'spacebro.space',
    'port': 3333,
    'client': {
        'name': 'python-bro'
    },
    'channelName': 'mychannelname'
}
spacebroClient = SpacebroClient(settings)
spacebroClient.wait()
  1. Emit a message for an app called node-bro
from pySpacebroClient import SpacebroClient

settings = {
    'host': 'spacebro.space',
    'port': 3333,
    'client': {
        'name': 'python-bro'
    },
    'channelName': 'mychannelname',
    'out': {
        'outMedia': {
            'eventName': 'outMedia',
            'description': 'Output media',
            'type': 'all'
        }
    },
    'connection': 'python-bro/outMedia => node-bro/inMedia'
}
spacebroClient = SpacebroClient(settings)
spacebroClient.emit(settings.out.outMedia.eventName, {'value': 5})
spacebroClient.wait()
  1. Receive a message from an app called chokibro
from pySpacebroClient import SpacebroClient

def on_inMedia(self, args):
    print('received', args)

settings = {
    'host': 'spacebro.space',
    'port': 3333,
    'client': {
        'name': 'python-bro'
    },
    'channelName': 'mychannelname',
    'in': {
        'inMedia': {
            'eventName': 'inMedia',
            'description': 'Input media',
            'type': 'all'
        }
    },
    'connection': 'chokibro/outMedia => python-bro/inMedia'
}
spacebroClient = SpacebroClient(settings)
spacebroClient.on(settings['in'].inMedia.eventName, self.on_inMedia)
spacebroClient.wait()

test command

python -m tests.test

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
pySpacebroClient-0.0.3-py2-none-any.whl (4.7 kB) Copy SHA256 hash SHA256 Wheel py2
pySpacebroClient-0.0.3.tar.gz (4.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page