本文整理汇总了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
})
示例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)
示例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) )
示例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,
}
)
示例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)
示例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)