Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spacebro/pyspacebroclient
Connect easily to a spacebro server
https://github.com/spacebro/pyspacebroclient
Last synced: 13 days ago
JSON representation
Connect easily to a spacebro server
- Host: GitHub
- URL: https://github.com/spacebro/pyspacebroclient
- Owner: spacebro
- License: mit
- Created: 2017-07-27T11:17:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-28T13:26:51.000Z (over 7 years ago)
- Last Synced: 2024-12-21T12:21:03.964Z (about 1 month ago)
- Language: Python
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
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
------------.. code:: bash
pip install pySpacebroClient
Usage
-----1. Connect
.. code:: python
from pySpacebroClient import SpacebroClient
settings = {
'host': 'spacebro.space',
'port': 3333,
'client': {
'name': 'python-bro'
},
'channelName': 'mychannelname'
}
spacebroClient = SpacebroClient(settings)
spacebroClient.wait()2. Emit a message for an app called `node-bro`
.. code:: python
from pySpacebroClient import SpacebroClient
settings = {
'host': 'spacebro.space',
'port': 3333,
'client': {
'name': 'python-bro'
'out': {
'outMedia': {
'eventName': 'outMedia',
'description': 'Output media',
'type': 'all'
}
}
},
'channelName': 'mychannelname',
'connection': 'python-bro/outMedia => node-bro/inMedia'
}
spacebroClient = SpacebroClient(settings)
spacebroClient.emit(settings.client.out.outMedia.eventName, {'value': 5})
spacebroClient.wait()3. Receive a message from an app called `chokibro`
.. code:: python
from pySpacebroClient import SpacebroClient
def on_inMedia(self, args):
print('received', args)settings = {
'host': 'spacebro.space',
'port': 3333,
'client': {
'name': 'python-bro'
'in': {
'inMedia': {
'eventName': 'inMedia',
'description': 'Input media',
'type': 'all'
}
}
},
'channelName': 'mychannelname',
'connection': 'chokibro/outMedia => python-bro/inMedia'
}
spacebroClient = SpacebroClient(settings)
spacebroClient.on(settings.client['in'].inMedia.eventName, self.on_inMedia)
spacebroClient.wait()test command
============.. code:: bash
python -m tests.test