python的pusher-websocket客户端

pusherclient的Python项目详细描述


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

Pusher客户端

pusherclient是一个python模块,用于处理pusher websockets

安装

只需运行“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第三方库


热门话题
使用odbc的java数据库连接:找不到microsoft access驱动程序(*.mdb*.accdb)选项   java我在将文本读入数组时遇到问题,我需要在这段代码中更改什么?   java JAXB元素列表中缺少字段   java Android BaseAdapter,返回项id   登录到web应用程序的java语音识别   java线性布局不填充滚动视图中屏幕的剩余部分   java如何通过点击第二个按钮来显示第二张壁纸?   java如果使用无缓冲I/O,缓冲I/O如何减少开销?   《骑士之旅》中的java问题   java如何解决Singelton为空的问题   java可在后台播放广告   在Swing中处理JFXPanel时发生java JavaFX非法状态异常   java Contains总是返回false   java ZeroMQ两个PUBSUB代理