コード例 #1
0
            trips['avg'] = (trips['avg'] + trips[last_trip]) / 2

    ## Increment Trip Counter
    trips[current_trip] = trips[current_trip] + 1

    ## Update Max
    if trips[current_trip] > trips['max']:
        trips['max'] = trips[current_trip]

    print(message)

    pubnub.publish({
        'channel':
        crazy,
        'message':
        current_trip + " Trip: " + str(trips[current_trip]) + " MAX: " +
        str(trips['max']) + "/sec " + " AVG: " + str(trips['avg']) + "/sec"
    })


pubnub.subscribe({
    'channel': crazy,
    'connect': connected,
    'callback': received
})

## -----------------------------------------------------------------------
## IO Event Loop
## -----------------------------------------------------------------------
pubnub.start()
コード例 #2
0
## PubNub Real-time Push APIs and Notifications Framework
## Copyright (c) 2010 Stephen Blum
## http://www.pubnub.com/


import sys
from pubnub import PubnubTwisted 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'


# Asynchronous usage

def callback(message):
    print(message)

pubnub.here_now(channel, callback=callback, error=callback)

pubnub.start()
コード例 #3
0
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()
コード例 #4
0
ファイル: test_grant_async.py プロジェクト: FahadMonir/python
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()
コード例 #5
0
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()
コード例 #6
0
ファイル: unit-test-full.py プロジェクト: vivek8943/python
        def dumpster(message):
            test(0, 'never see this')

        pubnub.subscribe({
            'channel': crazy,
            'connect': done,
            'callback': dumpster
        })

    def connected():
        pubnub.publish({
            'channel': crazy,
            'message': {'Info': 'Connected!'}
        })

    pubnub.subscribe({
        'channel': crazy,
        'connect': connected,
        'callback': message_received
    })

    phase2()

## -----------------------------------------------------------------------
## Run Tests
## -----------------------------------------------------------------------
test_pubnub(pubnub_user_supplied_options)
test_pubnub(pubnub_high_security)
pubnub_high_security.start()
コード例 #7
0
	pubnub_enc.subscribe(channel, callback=_cb, connect=_connect, error=_error)

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_enc.start()