当前位置: 首页>>代码示例>>Python>>正文


Python PubNubAsyncio.here_now方法代码示例

本文整理汇总了Python中pubnub.pubnub_asyncio.PubNubAsyncio.here_now方法的典型用法代码示例。如果您正苦于以下问题:Python PubNubAsyncio.here_now方法的具体用法?Python PubNubAsyncio.here_now怎么用?Python PubNubAsyncio.here_now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pubnub.pubnub_asyncio.PubNubAsyncio的用法示例。


在下文中一共展示了PubNubAsyncio.here_now方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_here_now_super_call

# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import here_now [as 别名]
def test_here_now_super_call(event_loop):
    pubnub = PubNubAsyncio(pnconf_pam_copy(), custom_event_loop=event_loop)
    pubnub.config.uuid = 'test-here-now-asyncio-uuid1'

    env = yield from pubnub.here_now().future()
    assert isinstance(env.result, PNHereNowResult)

    env = yield from pubnub.here_now().channel_groups("gr").include_uuids(True).include_state(True).future()
    assert isinstance(env.result, PNHereNowResult)

    env = yield from pubnub.here_now().channels('ch.bar*').channel_groups("gr.k").future()
    assert isinstance(env.result, PNHereNowResult)

    env = yield from pubnub.here_now().channels(['ch.bar*', 'ch2']).channel_groups("gr.k").future()
    assert isinstance(env.result, PNHereNowResult)

    pubnub.stop()
开发者ID:,项目名称:,代码行数:19,代码来源:

示例2: test_multiple_channels

# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import here_now [as 别名]
def test_multiple_channels(event_loop, sleeper=asyncio.sleep):
    pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
    pubnub.config.uuid = 'test-here-now-asyncio-uuid1'

    ch1 = "test-here-now-asyncio-ch1"
    ch2 = "test-here-now-asyncio-ch2"

    callback = VCR599Listener(1)
    pubnub.add_listener(callback)
    pubnub.subscribe().channels([ch1, ch2]).execute()

    yield from callback.wait_for_connect()

    yield from sleeper(5)
    env = yield from pubnub.here_now() \
        .channels([ch1, ch2]) \
        .future()

    assert env.result.total_channels == 2
    assert env.result.total_occupancy >= 1

    channels = env.result.channels

    assert len(channels) == 2
    assert channels[0].occupancy == 1
    assert channels[0].occupants[0].uuid == pubnub.uuid
    assert channels[1].occupancy == 1
    assert channels[1].occupants[0].uuid == pubnub.uuid

    result = yield from pubnub.here_now() \
        .channels([ch1, ch2]) \
        .include_state(True) \
        .result()

    assert result.total_channels == 2

    pubnub.unsubscribe().channels([ch1, ch2]).execute()
    yield from callback.wait_for_disconnect()

    pubnub.stop()
开发者ID:,项目名称:,代码行数:42,代码来源:

示例3: test_global

# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import here_now [as 别名]
def test_global(event_loop, sleeper=asyncio.sleep):
    pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
    pubnub.config.uuid = 'test-here-now-asyncio-uuid1'

    ch1 = "test-here-now-asyncio-ch1"
    ch2 = "test-here-now-asyncio-ch2"

    callback = VCR599Listener(1)
    pubnub.add_listener(callback)
    pubnub.subscribe().channels([ch1, ch2]).execute()

    yield from callback.wait_for_connect()

    yield from sleeper(5)

    env = yield from pubnub.here_now().future()

    assert env.result.total_channels >= 2
    assert env.result.total_occupancy >= 1

    pubnub.unsubscribe().channels([ch1, ch2]).execute()
    yield from callback.wait_for_disconnect()

    pubnub.stop()
开发者ID:,项目名称:,代码行数:26,代码来源:


注:本文中的pubnub.pubnub_asyncio.PubNubAsyncio.here_now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。