Multiplexed connection's on_open method #24

Alerion opened this Issue Feb 7, 2012 · 1 comment


None yet
2 participants

Alerion commented Feb 7, 2012

For example we have two multiplexed connections:

class RouterConnection(tornadio2.conn.SocketConnection):
    __endpoints__ = {
        '/admin': AdminConnection,
        '/user': UserConnection

We need authentication only for AdminConnection, butAdminConnection.on_open does not affect connection process. I mean returning False does not abort connection.

Alerion commented Feb 7, 2012

Maybe this will be usefull. Changed Session.connect_endpoint and little hack to pass query string arguments to virtual connection.

def connect_endpoint(self, url):
    """Connect endpoint from URL.

    `url` endpoint URL.
    urldata = urlparse.urlparse(url)

    endpoint = urldata.path

    conn_class = self.conn.get_endpoint(endpoint)
    if conn_class is None:
        logging.error('There is no handler for endpoint %s' % endpoint)

    conn = conn_class(self, endpoint)

    args = copy.copy(self.request_arguments)
    info = ConnectionInfo(self.remote_ip, args, dict())

    result = conn.on_open(info)

    if result is not None and not result:

    self.endpoints[endpoint] = conn

@mrjoes mrjoes closed this in 955758d Feb 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment