pubnub.publish({ 'channel': channel, 'message': message, 'callback': publish_cb }) time.sleep(5) pubnub.here_now({ 'channel': channel, 'callback': here_now_cb }) def subscribe_cb(response): test(response == message, 'Here Now Test: Subscribe Receive Test in subscribe Callback') pubnub.subscribe({ 'channel': channel, 'connect': subscribe_connect_cb, 'callback': subscribe_cb }) expect = 7 test_publish() test_history() test_subscribe() test_here_now() pubnub.start() if failures > 0: raise Exception('Fail', failures)
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()
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()
'callback': (lambda x: x) }) 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()