python的pusher-websocket客户端

pusherclientb的Python项目详细描述


[![生成状态](https://travis-ci.org/bartbroere/PythonPusherClient.svg?branch=master)](https://travis-ci.org/bartbroere/PythonPusherClient

推动客户机b

pusherclientb是一个用于处理pusher websockets的python模块。这是由erik kulyk编写的原始(pusherclient)的分支版本。它完全向后兼容,并且在回调中提供解码消息和自定义参数。

安装

只需运行“python setup.py install”。

此模块依赖于websocket客户端模块,可从以下位置获得:<;http://github.com/liris/websocket-client>;

示例

使用此Pusher客户端使用WebSocket的示例:

import pusherclient

# Add a logging handler so we can see the raw communication data
import logging
root = logging.getLogger()
root.setLevel(logging.INFO)
ch = logging.StreamHandler(sys.stdout)
root.addHandler(ch)

global pusher

# We can't subscribe until we've connected, so we use a callback handler
# to subscribe when able
def connect_handler(data):
    channel = pusher.subscribe('mychannel')
    channel.bind('myevent', callback)

pusher = pusherclient.Pusher(appkey)
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()

while True:
    # Do other things in the meantime here...
    time.sleep(1)

只需使用pusher提供的pusher客户机即可将pusher事件发送到通道。你可以在这里得到:<;http://github.com/newbamboo/pusher_client_python>;

import pusher pusher.app_id = app_id pusher.key = appkey

p = pusher.Pusher() p[‘mychannel’].trigger(‘myevent’, ‘mydata’)

谢谢

使用来自<;http://github.com/liris/websocket-client>;的WebSocket客户端模块构建。 logan koester的ruby gem也提供了类似的服务,对我们的参考也很有帮助。请看这里:<;http://github.com/logankoester/pusher-client>;。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何下载多个。java中的PDF文件   linux Java打开文件,形成实际用户主页~/   java如何在时间线内维护TableView选择?   java Hibernate注释@Where vs@WhereJoinTable   Java读/写访问异常FileNotFoundException(访问被拒绝)   继承在Java中是否可以扩展最后一个类?   Android HttpClient使用java使应用程序崩溃。lang.OutOfMemoryError:pthread_create   java为什么即使我在proguardproject中添加了jar文件,也会出现这种错误。txt?   如果添加JButton,swing Java FocusListener和KeyListener将无法工作   java使用solrj检索json格式的SolrDocument   使用Microsoft Visual Studio代码进行Java编程   java NoClassDefFoundError:org/apache/log4j/Logger   哈希集中包含相等对象的java   java中的参数化构造函数是否需要有一个主体?   java类似于NetBeans不必要的代码检测器   Java实践问题   java Blackberry“[projectname].调试文件丢失”和“I/O错误:找不到程序”jar