1

PubNub,对于实时通信来说真的很棒。根据 pubnub 团队提供的文档,我已经完成了subscribepublish例如,它的工作正常。

现在想知道如何在 Python(GAE)应用程序中使用 PubNub 频道获得特定用户已经/存在,但我没有找到如何在服务器端和客户端实现此功能的完整指南。

注意:我在这里使用 Python Google App Engine 和 Javascript。

4

1 回答 1

1

PubNub presence is a way to follow up on joins/leaves in a channel, what you need is the here_now feature if I understand correctly,

Taken from the Pyton lib is (https://github.com/pubnub/pubnub-api/tree/master/python/)

here_now = pubnub.here_now({
'channel' : 'hello_world',
})

print(here_now['occupancy'])
print(here_now['uuids'])

And now you can iterate on whoever is in the channel right now, this can't be done in the javascript though so you'd have to have perhaps another channel for each of your real channels that you can send the information from the server-side to the client side and then update something accordingly.

于 2013-04-03T11:15:15.907 回答