🌟 Connect easily to a [spacebro server](https://github.com/spacebro/spacebro).
a port of nodejs spacebro-client
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.
pip install pySpacebroClient
- Connect
from pySpacebroClient import SpacebroClient
settings = {
'host': 'spacebro.space',
'port': 3333,
'client': {
'name': 'python-bro'
},
'channelName': 'mychannelname'
}
spacebroClient = SpacebroClient(settings)
spacebroClient.wait()
- Emit a message for an app called node-bro
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()
- 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'
'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()
python -m tests.test