轻松连接SpaceBro服务器
pySpacebroClient的Python项目详细描述
pyspacebroclient
轻松连接到[spacebro服务器](https://github.com/spacebro/spacebro)。
nodejs的端口spacebro-client
为什么
不再自定义socket.io服务器。
轻松地将socket.io连接到其他客户端。
spacebro提供了一个api来连接客户端的输入和输出。
安装
pip install pySpacebroClient
使用量
- 连接
frompySpacebroClientimportSpacebroClientsettings={'host':'spacebro.space','port':3333,'client':{'name':'python-bro'},'channelName':'mychannelname'}spacebroClient=SpacebroClient(settings)spacebroClient.wait()
- 为名为node bro的应用程序发出消息
frompySpacebroClientimportSpacebroClientsettings={'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()
- 从名为Chokibro的应用程序接收消息
frompySpacebroClientimportSpacebroClientdefon_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()
测试命令
python -m tests.test