Example #1
0
x = 5
def run_test(t):
	global x
	x += 5
	i = (x / 5) - 1
	def _print():
		print('Running test ' + str(i))
	pubnub.timeout(x, _print)
	pubnub.timeout(x + 1,t)

def stop():
	pubnub.stop()

run_test(test_1)
run_test(test_2)
run_test(test_3)
run_test(test_4)
run_test(test_5)
run_test(test_6)
run_test(test_7)
run_test(test_8)
run_test(test_9)
run_test(test_10)
run_test(test_11)
run_test(stop)


pubnub_pam.start()


Example #2
0
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from pubnub import PubnubTornado as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo'
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 = 'hello_world'
message = 'Hello World !!!'

# Asynchronous usage


def callback(message):
    print(message)

pubnub.publish(channel, message, callback=callback, error=callback)

pubnub.start()
Example #3
0
# http://www.pubnub.com/


import sys

from pubnub import PubnubTornado as Pubnub

publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
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 = 'hello_world'
authkey = "abcd"


def callback(message):
    print(message)
    pubnub.stop()


pubnub.revoke(channel, authkey, callback=callback, error=callback)

pubnub.start()
def run_test(t):
    global x
    x += 5
    i = (x / 5) - 1

    def _print():
        print('Running test ' + str(i))

    pubnub.timeout(x, _print)
    pubnub.timeout(x + 1, t)


def stop():
    pubnub.stop()


run_test(test_1)
run_test(test_2)
run_test(test_3)
run_test(test_4)
run_test(test_5)
run_test(test_6)
run_test(test_7)
run_test(test_8)
run_test(test_9)
run_test(test_10)
run_test(test_11)
run_test(stop)

pubnub_enc.start()