本文整理汇总了Python中Pubnub.Pubnub.time方法的典型用法代码示例。如果您正苦于以下问题:Python Pubnub.time方法的具体用法?Python Pubnub.time怎么用?Python Pubnub.time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub.Pubnub
的用法示例。
在下文中一共展示了Pubnub.time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import time [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) )
示例2: test
# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import time [as 别名]
## ---------------------------------------------------------------------------
## Unit Test Function
## ---------------------------------------------------------------------------
def test( trial, name ) :
if trial :
print( 'PASS: ' + name )
else :
print( 'FAIL: ' + name )
## -----------------------------------------------------------------------
## 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
示例3: test
# 需要导入模块: from Pubnub import Pubnub [as 别名]
# 或者: from Pubnub.Pubnub import time [as 别名]
## ---------------------------------------------------------------------------
def test(trial, name):
if trial:
print("PASS: " + name)
else:
print("FAIL: " + name)
## -----------------------------------------------------------------------
## 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)