本文整理汇总了Python中pubnub.pubnub_asyncio.PubNubAsyncio.unsubscribe_all方法的典型用法代码示例。如果您正苦于以下问题:Python PubNubAsyncio.unsubscribe_all方法的具体用法?Python PubNubAsyncio.unsubscribe_all怎么用?Python PubNubAsyncio.unsubscribe_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pubnub.pubnub_asyncio.PubNubAsyncio
的用法示例。
在下文中一共展示了PubNubAsyncio.unsubscribe_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unsubscribe_all
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import unsubscribe_all [as 别名]
def test_unsubscribe_all(event_loop, sleeper=asyncio.sleep):
pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
pubnub.config.uuid = "test-subscribe-asyncio-messenger"
ch = "test-subscribe-asyncio-unsubscribe-all-ch"
ch1 = "test-subscribe-asyncio-unsubscribe-all-ch1"
ch2 = "test-subscribe-asyncio-unsubscribe-all-ch2"
ch3 = "test-subscribe-asyncio-unsubscribe-all-ch3"
gr1 = "test-subscribe-asyncio-unsubscribe-all-gr1"
gr2 = "test-subscribe-asyncio-unsubscribe-all-gr2"
envelope = yield from pubnub.add_channel_to_channel_group().channel_group(gr1).channels(ch).future()
assert envelope.status.original_response['status'] == 200
envelope = yield from pubnub.add_channel_to_channel_group().channel_group(gr2).channels(ch).future()
assert envelope.status.original_response['status'] == 200
yield from sleeper(1)
callback_messages = VCR599Listener(1)
pubnub.add_listener(callback_messages)
pubnub.subscribe().channels([ch1, ch2, ch3]).channel_groups([gr1, gr2]).execute()
yield from callback_messages.wait_for_connect()
assert len(pubnub.get_subscribed_channels()) == 3
assert len(pubnub.get_subscribed_channel_groups()) == 2
pubnub.unsubscribe_all()
yield from callback_messages.wait_for_disconnect()
assert len(pubnub.get_subscribed_channels()) == 0
assert len(pubnub.get_subscribed_channel_groups()) == 0
envelope = yield from pubnub.remove_channel_from_channel_group().channel_group(gr1).channels(ch).future()
assert envelope.status.original_response['status'] == 200
envelope = yield from pubnub.remove_channel_from_channel_group().channel_group(gr2).channels(ch).future()
assert envelope.status.original_response['status'] == 200
pubnub.stop()