Esempio n. 1
0
## 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 = 'a'


# Asynchronous usage
def callback(message, channel):
    print(message)


def error(message):
    print("ERROR : " + str(message))


def connect(message):
    print("CONNECTED")
Esempio n. 2
0

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'


# Asynchronous usage

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


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

pubnub.start()
Esempio n. 3
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()
Esempio n. 4
0

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 'abcd'
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 = 'ab'


# Asynchronous usage

def callback_abc(message, channel, real_channel):
    print(str(message) + ' , ' + channel + ', ' + real_channel)
    pubnub.unsubscribe_group(channel_group='abc')
    pubnub.stop()


def callback_d(message, channel):
    print(str(message) + ' , ' + channel)
Esempio n. 5
0
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 'abcd'
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 = 'ab'

# Asynchronous usage


def callback_abc(message, channel, real_channel):
    print(str(message) + ' , ' + channel + ', ' + real_channel)
    #pubnub.unsubscribe_group(channel_group='abc')
    #pubnub.stop()


def callback_d(message, channel):
Esempio n. 6
0
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 = 'a'

# Asynchronous usage


def callback(message):
    print(message)


pubnub.history(channel, count=2, callback=callback, error=callback)

pubnub.start()
Esempio n. 7
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.grant(channel, authkey, True, True, callback=callback, error=callback)

pubnub.start()
Esempio n. 8
0
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 = 'a'


# Asynchronous usage
def callback(message, channel):
    print(message)


def error(message):
    print("ERROR : " + str(message))

Esempio n. 9
0

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 'abcd'
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 = 'ab'


# Asynchronous usage

def callback_abc(message, channel, real_channel):
    print(str(message) + ' , ' + channel + ', ' + real_channel)
    # pubnub.unsubscribe_group(channel_group='abc')
    # pubnub.stop()


def callback_d(message, channel):
    print(str(message) + ' , ' + channel)
Esempio n. 10
0
import time
# from twisted.trial import unittest

from pubnub import PubnubTornado as Pubnub

pubkey = "pub-c-37d3c709-c35e-487a-8b33-2314d9b62b28"
subkey = "sub-c-cd0b6288-cdf5-11e5-bcee-0619f8945a4f"
pubnub = Pubnub(pubkey, subkey)
pubnub_enc = Pubnub(pubkey, subkey, cipher_key="enigma")


# class PublishTests(unittest.TestCase):
def test_1():
    channel = "test_1-" + str(time.time())
    message = "I am a string"

    def _cb(resp, ch=None):
        assert resp == message
        pubnub.unsubscribe(channel)

    def _connect(resp):
        def _cb1(resp, ch=None):
            assert resp[0] == 1

        def _err1(resp):
            assert False

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

    def _error(resp):
        assert False
Esempio n. 11
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.audit(channel, auth_key=authkey, callback=callback, error=callback)

pubnub.start()
Esempio n. 12
0

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 = 'a'


# Asynchronous usage


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


pubnub.history(channel, count=2, callback=callback, error=callback)

pubnub.start()
Esempio n. 13
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.audit(channel, authkey, callback=callback, error=callback)

pubnub.start()
Esempio n. 14
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.grant(channel, authkey, True, True, callback=callback, error=callback)

pubnub.start()
Esempio n. 15
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()
Esempio n. 16
0
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'

# Asynchronous usage


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


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

pubnub.start()
Esempio n. 17
0

from pubnub import PubnubTornado as Pubnub
import time

pubnub = Pubnub("demo","demo")
pubnub_pam = Pubnub("pub-c-c077418d-f83c-4860-b213-2f6c77bde29a", 
	"sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe", "sec-c-OGU3Y2Q4ZWUtNDQwMC00NTI1LThjNWYtNWJmY2M4OGIwNjEy")



# Grant permission read true, write true, on channel ( Async Mode )
def test_1():

	def _callback(resp, ch= None):
		assert resp == {
									'message': u'Success',
									'payload': {u'auths': {u'abcd': {u'r': 1, u'w': 1}},
									u'subscribe_key': u'sub-c-e8839098-f568-11e2-a11a-02ee2ddab7fe',
									u'level': u'user', u'channel': u'abcd', u'ttl': 1} 
								}

	def _error(response):
		assert False

	pubnub_pam.grant(channel="abcd", auth_key="abcd", read=True, write=True, ttl=1, callback=_callback, error=_error)
							

# Grant permission read false, write false, on channel ( Async Mode )
def test_2():
	
Esempio n. 18
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.revoke(channel, authkey, callback=callback, error=callback)

pubnub.start()