# Path: deepstreampy/client.py
# @gen.coroutine
# def connect(url, **options):
#     """Establish a connection to a deepstream.io server.
# 
#     Args:
#         url (string): URL to connect to
#         **options: The options for the client
# 
#     Returns:
#         tornado.concurrent.Future: A future that resolves with an instance of
#             ``deepstreampy.client.Client`` when a connection is established. If
#             the client is unable to connect, the future will have the
#             appropriate exception set.
#     """
#     client = Client(url, **options)
#     yield client.connect()
#     raise gen.Return(client)
# 
# Path: deepstreampy/rpc.py
# class RPCResponse(object):
# class RPCException(Exception):
# class RPC(object):
# class RPCHandler(object):
#     def __init__(self, connection, name, correlation_id):
#     def ack(self):
#     def reject(self):
#     def send(self, data):
#     def error(self, error_str):
#     def _perform_auto_ack(self):
#     def __init__(self, message):
#     def __init__(self, future, client, **options):
#     def ack(self):
#     def respond(self, data):
#     def error(self, error_msg):
#     def _complete(self):
#     def __init__(self, connection, client, **options):
#     def provide(self, name, callback):
#     def unprovide(self, name):
#     def make(self, name, data):
#     def _get_rpc(self, correlation_id, rpc_name, raw_message):
#     def _respond_to_rpc(self, message):
#     def handle(self, message):
#     def _reprovide(self):


from deepstreampy import connect
from deepstreampy import rpc
from tornado import gen
from tornado import ioloop
import signal
    if isinstance(x, int):
        response.send(x * x)
    else:
        response.error("sq received unexpected input")


@gen.coroutine
def run():
    # First we set up the provider
    provider = yield connect("ws://localhost:6020/deepstream")
    yield provider.login({"username": "A"})
    provider.on('error', lambda msg, event, topic: print('a provider error occured'))

    yield provider.rpc.provide("sq", sq)

    # Then we set up the consumer
    consumer = yield connect("ws://localhost:6020/deepstream")
    yield consumer.login({"username": "B"})
    consumer.on('error', lambda msg, event, topic: print('a consumer error occured'))

    # Next we make an RPC call to the "sq" function
    result = yield consumer.rpc.make("sq", 2)
    print(result)
    # Output: 4

    # In case the provider ends up sending an error message, an exception
    # with that message will be raised when trying to get the result of the
    # call.
    try:
        yield consumer.rpc.make("sq", "2")

# Path: deepstreampy/client.py
# @gen.coroutine
# def connect(url, **options):
#     """Establish a connection to a deepstream.io server.
# 
#     Args:
#         url (string): URL to connect to
#         **options: The options for the client
# 
#     Returns:
#         tornado.concurrent.Future: A future that resolves with an instance of
#             ``deepstreampy.client.Client`` when a connection is established. If
#             the client is unable to connect, the future will have the
#             appropriate exception set.
#     """
#     client = Client(url, **options)
#     yield client.connect()
#     raise gen.Return(client)
# 
# Path: deepstreampy/rpc.py
# class RPCResponse(object):
# class RPCException(Exception):
# class RPC(object):
# class RPCHandler(object):
#     def __init__(self, connection, name, correlation_id):
#     def ack(self):
#     def reject(self):
#     def send(self, data):
#     def error(self, error_str):
#     def _perform_auto_ack(self):
#     def __init__(self, message):
#     def __init__(self, future, client, **options):
#     def ack(self):
#     def respond(self, data):
#     def error(self, error_msg):
#     def _complete(self):
#     def __init__(self, connection, client, **options):
#     def provide(self, name, callback):
#     def unprovide(self, name):
#     def make(self, name, data):
#     def _get_rpc(self, correlation_id, rpc_name, raw_message):
#     def _respond_to_rpc(self, message):
#     def handle(self, message):
#     def _reprovide(self):


# Path: examples/rpc_example.py
from deepstreampy import connect
from deepstreampy import rpc
from tornado import gen
from tornado import ioloop
import signal

    if isinstance(x, int):
        response.send(x * x)
    else:
        response.error("sq received unexpected input")


@gen.coroutine
def run():
    # First we set up the provider
    provider = yield connect("ws://localhost:6020/deepstream")
    yield provider.login({"username": "A"})
    provider.on('error', lambda msg, event, topic: print('a provider error occured'))

    yield provider.rpc.provide("sq", sq)

    # Then we set up the consumer
    consumer = yield connect("ws://localhost:6020/deepstream")
    yield consumer.login({"username": "B"})
    consumer.on('error', lambda msg, event, topic: print('a consumer error occured'))

    # Next we make an RPC call to the "sq" function
    result = yield consumer.rpc.make("sq", 2)
    print(result)
    # Output: 4

    # In case the provider ends up sending an error message, an exception
    # with that message will be raised when trying to get the result of the
    # call.
    try:
        yield consumer.rpc.make("sq", "2")

    except rpc.RPCException as e: