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


Python Pubnub.history方法代码示例

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


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

示例1: time_complete

# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import history [as 别名]
## Time Example
## -----------------------------------------------------------------------
def time_complete(timestamp):
    print(timestamp)

pubnub.time({ 'callback' : time_complete })

## -----------------------------------------------------------------------
## History Example
## -----------------------------------------------------------------------
def history_complete(messages):
    print(messages)

pubnub.history( {
    'channel'  : crazy,
    'limit'    : 10,
    'callback' : history_complete
})

## -----------------------------------------------------------------------
## Publish Example
## -----------------------------------------------------------------------
def publish_complete(info):
    print(info)

pubnub.publish({
    'channel' : crazy,
    'message' : "Hello World",
    'callback' : publish_complete
})
开发者ID:Vall3y,项目名称:pubnub-api,代码行数:32,代码来源:unit-test.py

示例2: len

# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import history [as 别名]

import sys
from Pubnub import Pubnub

publish_key =  'pub-c-6c6b1294-7fdd-4f33-aec4-41217a6d0b6c'
subscribe_key = 'sub-c-cf0e18e6-bd43-11e4-861a-0619f8945a4f'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo'
cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False

## -----------------------------------------------------------------------
## Initiate Pubnub State
## -----------------------------------------------------------------------
pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
                secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
channel = 'my_channel'

# Synchronous usage

print pubnub.history(channel, count=10)




# Asynchronous usage
def callback(message):
    print(message)

pubnub.history(channel, count=10, callback=callback, error=callback)
开发者ID:behappytester,项目名称:PythonSampleCodes,代码行数:31,代码来源:history.py

示例3: print

# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import history [as 别名]
    else :
        print( 'FAIL: ' + name )

## -----------------------------------------------------------------------
## Publish Example
## -----------------------------------------------------------------------
publish_success = pubnub.publish({
    'channel' : crazy,
    'message' : crazy
})
test( publish_success[0] == 1, 'Publish First Message Success' )

## -----------------------------------------------------------------------
## History Example
## -----------------------------------------------------------------------
history = pubnub.history({
    'channel' : crazy,
    'limit'   : 1
})
test(
    history[0].encode('utf-8') == crazy,
    'History Message: ' + history[0]
)
test( len(history) == 1, 'History Message Count' )

## -----------------------------------------------------------------------
## PubNub Server Time Example
## -----------------------------------------------------------------------
timestamp = pubnub.time()
test( timestamp > 0, 'PubNub Server Time: ' + str(timestamp) )
开发者ID:Mike-Forrester,项目名称:python,代码行数:32,代码来源:unit-test.py

示例4: time_complete

# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import history [as 别名]
## Time Example
## -----------------------------------------------------------------------
def time_complete(timestamp):
    print(timestamp)


pubnub.time({"callback": time_complete})

## -----------------------------------------------------------------------
## History Example
## -----------------------------------------------------------------------
def history_complete(messages):
    print(messages)


pubnub.history({"channel": crazy, "limit": 10, "callback": history_complete})

## -----------------------------------------------------------------------
## Publish Example
## -----------------------------------------------------------------------
def publish_complete(info):
    print(info)


pubnub.publish(
    {
        "channel": crazy,
        "message": {"one": "Hello World! --> ɂ顶@#$%^&*()!", "two": "hello2"},
        "callback": publish_complete,
    }
)
开发者ID:edgarcaixm,项目名称:pubnub-api,代码行数:33,代码来源:unit-test.py

示例5: Pubnub

# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import history [as 别名]
from Pubnub import Pubnub

## THIS BIT ALLOWS US TO USE "urlfetch" from GAE while running from 
## Not needed in runtime 
from google.appengine.api import apiproxy_stub_map
from google.appengine.api import urlfetch_stub

# Create a stub map so we can build App Engine mock stubs.
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()

# Register App Engine mock stubs.
apiproxy_stub_map.apiproxy.RegisterStub(
    'urlfetch', urlfetch_stub.URLFetchServiceStub())
## -------------------------------------------------------------



## Initiat Class
pubnub = Pubnub( 'demo', 'demo', None, False )

## History Example
history = pubnub.history({
    'channel' : 'hello_world',
    'limit'   : 1
})
print(history)

开发者ID:nickvelloff,项目名称:pubnub-gae-claw,代码行数:28,代码来源:history-example.py

示例6: Pubnub

# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import history [as 别名]
import sys

sys.path.append("../")
from Pubnub import Pubnub

## Initiat Class
pubnub = Pubnub("demo", "demo", None, False)

## History Example
history = pubnub.history({"channel": "hello_world", "limit": 1})
print(history)
开发者ID:pombredanne,项目名称:python-1,代码行数:13,代码来源:history-example.py


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