Beispiel #1
0
from configit import conf_from_file
config = conf_from_file('../development.py')

from BridgePython import Bridge
from lib import Wrap

bridge = Wrap(Bridge(api_key=config.public_api_key))
client = None

def service_response(resp):
    print(resp)

service = bridge.get_service('simple')
try:
    print 'trying 1'
    service.simple(simple='test 1', callback=service_response)
except TypeError as e:
    print(e)

try:
    print 'trying 2'
    service.simple('test 2', service_response)
except TypeError as e:
    print(e)

try:
    print 'trying 3'
    service.simple('test 3', callback=service_response)
except TypeError as e:
    print(e)
Beispiel #2
0
from configit import conf_from_file
config = conf_from_file('../development.py')

from BridgePython import Bridge
from lib import Wrap

class SimpleHandler(object):
    def simple(self, simple=None, callback=None):
        if simple and callback:
            callback('Simple is {0}'.format(simple))
        elif callback:
            callback('Simple not passed')

class AnotherSimpleHandler(object):
    def simple(self, simple, callback):
        if simple and callback:
            callback('Another Simple is {0}'.format(simple))
        elif callback:
            callback('Another Simple not passed')

bridge = Wrap(Bridge(api_key=config.private_api_key))
bridge.publish_service('simple', SimpleHandler())
bridge.publish_service('another', AnotherSimpleHandler())

bridge.connect()